View comments | RSS feed

gotoAndStop function

gotoAndStop([scene:String], frame:Object) : Void

Sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene.You can use the scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.

Availability: ActionScript 1.0; Flash Player 2

Parameters

scene:String [optional] - A string specifying the name of the scene to which the playhead is sent.

frame:Object - A number representing the frame number, or a string representing the label of the frame, to which the playhead is sent.

Example

In the following example, a document has two scenes: sceneOne and sceneTwo. Scene one contains a frame label on Frame 10 called newFrame, and two buttons, myBtn_btn and myOtherBtn_btn. This ActionScript is placed on Frame 1, Scene 1 of the main Timeline:


stop();

myBtn_btn.onRelease = function(){
 gotoAndStop("newFrame");
};

myOtherBtn_btn.onRelease = function(){
 gotoAndStop("sceneTwo", 1);
};

When the user clicks the buttons, the playhead moves to the specified location and stops.

See also

gotoAndStop (MovieClip.gotoAndStop method), stop function, play function, gotoAndPlay function


Version 8

Comments


No screen name said on Sep 14, 2005 at 8:51 PM :
The gotoAndPlay and gotoAndStop functions, using a variable or expression for the frame, will go to the WRONG FRAME if you use any scenes and do any rearranging of scene order.

Flash 8 (and all previous versions of Flash) generates incorrect action bytecodes when it compiles the script and the gotoAndPlay / gotoAndStop will go to a frame at an offset from the frame you specified ... even if you use frame labels.

It is best to avoid using the function form of gotoAndPlay and gotoAndStop .. always use the Movieclip method version instead, as this does not have the bug.
hoopdeee said on May 20, 2007 at 7:20 AM :
I put this code on frame 1 but nothing happens durring the test. The goto andstop does nothing at all. why? I have no named frames. However this code works in other movies. :o[
on (release){
skip = 1;
gotoAndStop("end");
}
There needs to be a simple tutorial for dummies.
juankpro said on Aug 1, 2007 at 8:42 AM :
To avoid the "rearranging the scenes bug" create en new FLA file with the scenes in the correct place (don't rearrange them) and copy frames from the original FLA file to the new one.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001733.html