tags:

views:

30

answers:

1

I am trying to build animation based on mathematical formulae(speed varying with time as per equations)- hence am charting x,y coordinates with formulae on user provider values, rather than inbuilt functions

In doing that, am struggling to get the timer right. for e.g if I set timer=new timer(1), object.x=object.x+1

the object doesn't zoom past screen within a second (or 600 milliseconds)- takes closer to 6-7 second to cover the 600 odd pixels. presume screen update doesnt work as fast as timer ticks

Is there a way for me to set up, such that I can predict speed on screen so animation takes abt 30 seconds?

A: 

Its better to use ENTER_FRAME listener and do animation there, based on current time (getTimer()).

Update: see getTimer() docs: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/utils/package.html#getTimer%28%29

Note the time when animation started. On each frame, subtract start time from current time. You get number of milliseconds passed. Compute coordinates/colors/rotations based on that number.

alxx
I still dont get this- timer is unpredictable. I tried using as follows http://pastebin.com/YSYxHNrn.
raghu
not clear how to use getTimer()... currently it moves 1 pixel for each buttonclick
raghu
getTimer() return number of milliseconds passed from application start - see the docs, you won't go far without them.
alxx