Andrew Rumm
Andrew Rumm

Reputation: 1278

Can I control motion tween speed according to timer?

I want to make simple motion tween of analog timer seconds arrow. Can i sync it with specified defined timer on AS3?

I know that the regular speed of animation can variate according to system specs. Any suggestions?

Thanx in advance!

Upvotes: 2

Views: 775

Answers (1)

apscience
apscience

Reputation: 7273

Given your requirements, I suggest that pure actionscript would be the way to go.

Your arrow should be a movieclip. With actionscript, we can change the rotation of the movieclip to make it rotate around like an analog clock. Frames are not a good way to keep track of time, so timers are the way to go.

Here's some sample code:

var secondTimer:Timer;
public function Arrow() {
    secondTimer = new Timer(1000); //1 second
    secondTimer.addEventListener(TimerEvent.TIMER, tickTock);
}
private function tickTock(e:TimerEvent){
    rotation += 6; //360 degrees, 60 seconds. 1 second = 6 degrees
}

Upvotes: 3

Related Questions