So I need to draw some custom shapes in Actionscript on canvas dynamically(like some spinning wheel made of lines and circles). I’m using Flash Builder.
Question 1:
What would work better(faster):
- Draw on graphics of canvas, on each frame clean everything and redraw?
- Create multiple Shape objects and transform them correspondingly?
Question 2:
How can I spin some Shape relatively to its center, but not relatively to its parent?(Tried playing with matrices but they work relatively to parent container). Maybe there is some push pop matrix functionality?
Question 1: Almost certainly using the Shapes directly will be faster. Flash Player will do a better job of updating the screen when not everything has to be redrawn, etc. However, it is usually better to write a short test when performance is a question.
Question 2:
ShapesareDisplayObjects, so you can just use therotationproperty, and they will rotate about their origin (the(0,0)point). Just make sure that you draw your shape relative to the origin, and move it to the right place using itsxyproperties (for example, for a 20×20 rectangle centered at (70,70)):