ActionScript 3.0 - Varying Movieclip framerates

I needed a situation where a single movieclip could be played at different frame rates. Though action script 3.0 has this neat way of dynamically varying the frame rate of the entire stage using

stage.frameRate

I found it not suiting enough to my requirement. And hence tries using the updateAfterEvent instead. The only fear I had was with it working fine in the player but not so in firefox and IE. And to my surprise it seems ok.

So to have your movieclip work at different framerates just do this.

1) Create a timer as shown below

var lTimer:Timer=new Timer(200,0);
lTimer.addEventListener(TimerEvent.TIMER,triggerUpdateClip)

2) Add a listener to this

function triggerUpdateClip(event:TimerEvent)
{
myClip.nextFrame();
event.updateAfterEvent();
}

Thats it.

Now vary the delay of the timer to increase or decrease the speed of the animation. Make sure you test it in different browsers as they all worked and handle timers differently.

Comments

Popular posts from this blog

Authoritative Server - MMO

Code dependencies