Posted By

andrewrench on 08/16/07


Tagged

actionscript navigation frame


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

andrewrench


Automatic Frame Navigation


 / Published in: ActionScript
 

URL: http://proto.layer51.com/d.aspx?f=647

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.

[u][b]Arguments[/b][/u]

[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.

[u][b]Usage[/b][/u]

//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) {
  2.  
  3. navigate = function(clipName) {
  4.  
  5. desiredFrameNumber = clipName._currentframe + numberOfFrames;
  6.  
  7. bContinue == "stop" ? clipName.gotoAndStop(desiredFrameNumber):clipName.gotoAndPlay(desiredFrameNumber);
  8.  
  9. clearInterval( clipName.autoframeNavigateID );
  10. }
  11.  
  12. this.autoframeNavigateID = setInterval(navigate, delay, this);
  13. }

Report this snippet  

You need to login to post a comment.