Manipulate drawn vectors using AS3

2019-05-31 00:35发布

问题:

What I want to do is draw a shape using the pen tool and then manipulate this shape using AS3 to distort the anchor points. How can I access the anchor points etc from within AS3? I can convert the drawn shape to a movie clip symbol, and access this from the Action Script, but how do I then manipulate the vector?

Thanks

回答1:

Unfortunately, you can't do it like that. A shape drawn in the IDE will not be editable once you export the swf.

If you want to create an animated element, you can draw with ActionScript, using the Graphics API, but you need to create your shape programmatically, and redraw the image every time an anchor changes.

If you actually want users to be able to draw in real time, there is no quick and easy way to do this, either: You need to create your own pen tool and anchors, draw lines between them, make them draggable, implement undo, etc.

Here are some "first steps" tutorials on how to do something like that in AS2 and AS3.



回答2:

You might try programatically drawing your shape, and then redraw it with new point information at an interval suitable for your animation, with either an ENTER_FRAME event or a timer.