User Guide
530 Chapter 2: ActionScript Language Reference
MovieClip.gotoAndPlay()
Availability
Flash Player 5.
Usage
my_mc.gotoAndPlay(frame:Object) : Void
Parameters
frame
A number representing the frame number, or a string representing the label of the frame,
to which the playhead is sent.
Returns
Nothing.
Description
Method; starts playing the SWF file at the specified frame. If you want to specify a scene as well as
a frame, use
gotoAndPlay().
You can extend the methods and event handlers of the MovieClip class by creating a subclass. For
more information, see “Assigning a class to a movie clip symbol” in Using ActionScript in Flash.
Example
The following example uses the _framesloaded property to start a SWF file when all the frames
are loaded. If all the frames aren’t loaded, the
_xscale property of the movie clip instance loader
is increased proportionally to create a progress bar.
Enter the following ActionScript in Frame 1 of the Timeline:
var pctLoaded:Number = Math.round(this.getBytesLoaded()/
this.getBytesTotal()*100);
bar_mc._xscale = pctLoaded;
Add the following code to Frame 2:
if (this._framesloaded<this._totalframes) {
this.gotoAndPlay(1);
} else {
this.gotoAndStop(3);
}
Place your content on or after Frame 3. Then add the following code to Frame 3:
stop();
See also
gotoAndPlay(), play()