Simple AS3 analog clock (2d)
May 7, 2008 — flaimhi,
Basing on the previous post (2d polygon generation) I’ve created a simple, ‘redrawing’ analog clock (in 2d).
Why complicate with polygons? Why not circles and lines from the drawing api?
- I wanted to have all the points coordinates (x,y) for later use with papervision3d. Drawing a circle using the Flash drawing API (graphics.*) will not give you such information.
Of course there are other methods to get the coordinates but this is probably the fastest one - additionaly we have full control of the number of vertexes we create.
How it works?
- The interval is Tweener based - it executes a function that gets the seconds/minutes/hours and then clears and redraws the polygons - once every second using a fake Sprite,
- polygons are drawn using the method from the previous post,
- entire clock is code based - no stage elements required.
The code
You can download the entire source here.
Have fun,
FLAIM
