Posted By

andrewrench on 08/16/07


actionscript navigation frame

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Automatic Frame Navigation

 / Published in: ActionScript


Requires Flash MX.

[b][u]autoframeNavigate[/u][/b] : This is to control any child movieClip or to control _root from inside child movieClips to go to a particular frame forward or backwards after a certain delay and then decides wether to play or stop from there.


[b]delay :[/b] amount of delay in seconds, the function waits for a period of time then jumps to the desired frame.

[b]bContinue :[/b] this is a string that can be either "stop" or "play" to decied whether you want to tell the movieClip or _root to stop at the desired frame or continue playing.

[b]numberOfFrames:[/b] number of frames to be skipped, this number can be positive to move forward or negative to move backwards.


//Use the following 2 statements to control the main timeline or any movieClip:- stop(); // wait for 3 seconds, then go to nextframe and continue playing. autoframeNavigate(3000, "play", 1)

//use the following 2 statements To control the main timeline from inside a child movieClip:- stop(); // wait for 3 seconds, tell _root to go backward 2 frames and stop there. _root.autoframeNavigate(3000, "stop", -2)

  1. MovieClip.prototype.autoframeNavigate = function(delay, bContinue, numberOfFrames) {
  3. navigate = function(clipName) {
  5. desiredFrameNumber = clipName._currentframe + numberOfFrames;
  7. bContinue == "stop" ? clipName.gotoAndStop(desiredFrameNumber):clipName.gotoAndPlay(desiredFrameNumber);
  9. clearInterval( clipName.autoframeNavigateID );
  10. }
  12. this.autoframeNavigateID = setInterval(navigate, delay, this);
  13. }

Report this snippet  

You need to login to post a comment.