gotoAndPlay() and gotoAndStop() in Flash Actionscript 3.0

gotoAndPlay() and gotoAndStop() are two function that help to control the playhead in flash movieclip. gotoAndPlay() cause the playhead to jump to the specified scene and frame and continue playing , where as gotoAndStop() causes the playhead to jump to the destination and stops from progressing further.


Usage

gotoAndPlay(frame:Object, scene:String = null):void
gotoAndStop(frame:Object, scene:String = null):void


Parameters

scene The scene name to which the playhead is sent. eg: “GameScene”

frame The frame number or label to which the playhead is sent. eg: 10 , “LoadFrame”

In AS 2.0 the order of scene and frame parameters to the functions are reversed. If only one parameter is passed, this value will be considered as the frame number or label. The play head will be moved to that frame in the present scene.


Eg:

mc1.gotoAndPlay(mc1.currentFrame + 10);//goes to frame number (mc1.currentFrame + 10
)

mc1.gotoAndPlay("Load", "Scene_Score");// Frame='Load', Scene='Scene_Score
'

gotoAndPlay("end"); // goes to frame labeled 'end' in the current scene
This entry was posted in Web Development. Bookmark the permalink.

4 Responses to gotoAndPlay() and gotoAndStop() in Flash Actionscript 3.0

  1. cik puan says:

    hai, i was wondering how the script to go to new scene and stop the sound from previous scene?

    for example my menu scene it has a background sound. When i click to go to new scene which is the content scene, it still play the background sound from the menu….

  2. Garrett says:

    I know this post is kinda old. But I am looking for a script were I can play frames 2 to 25. For example play a sequence of frames off a timeline inside of a MovieClip.

    Or I could load each sequence in an MC, then switch them out the MocieClips.

    Thanks in advance.
    Garrett

  3. SOSA says:

    SE USA ASI EN AS3.0

    gotoAndPlay(“Info”, 1); AS2
    gotoAndPlay(1,”Info”); AS3
    Es todo lo que cambia!

  4. stephen says:

    Hello,

    I got an error message when I tried to used the following code:

    gotoAndPlay(frame:1, scene:”logo_mc”);

    Do I use the movie clip anme or the layer name for the scene value?

    any assistance will be highly appreciated.

    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>