Use of gotoAndplay in AS 3.0

Hi,
I am learning and using as 3.0. It is really great.
But now I use some timeline scripts with author-environment
created clips.
clipA contains clip B.
Under clip B, in the script layer, I want to tell clip A to
go to frame 2 with the following script :
this.parent.gotoAndPlay("intro");
I got an error message telling that gotoAndPlay is not
defined.
How can I make such a simple and usual function work?
Thanks

Hi ritpas,
I've been working in a similar way with AS 3.0, with
gotoAndPlay(). Unless I'm not mistaken gotoAndPlay() is not looking
for the name of the movieclip or object, but instead wants
frame-number input.
In addition, I believe your syntax is slightly off. Instead
of this.parent.gotoAndPlay(), I believe it is
parent.this.gotoAndPlay(). You call the parent object first, then
the "sub-object" located in the parent.
So instead of using the script:
this.parent.gotoAndPlay("intro");
try
parent.this.gotoAndPlay(frame_number); // where frame_number
represents the frame you would like to play first.
Hope this helps,
Sam

Similar Messages

  • How to use nextScene.gotoandplay link using class property (external code.as)

    i try this code but i got error
    package  {
                            import flash.display.SimpleButton;
                            import flash.display.MovieClip;
                            import flash.events.MouseEvent;
                            public class np extends SimpleButton {
                            public function np() {
                                                    this.addEventListener(MouseEvent.CLICK, clickF);
                                                    private function clickF(e:MouseEvent):void{
                                                    MovieClip(this.root).nextScene(),gotoAndStop(1);
    Call to possibly undefined method gotoanStop
    Note: i want to go next scene

    Thx guys
    I got the solution
    package  {
                            import flash.display.SimpleButton;
                            import flash.display.MovieClip;
                            import flash.events.MouseEvent;
                            public class np extends SimpleButton {
                            public function np() {
                                                    this.addEventListener(MouseEvent.CLICK, clickF);
                                                    private function clickF(e:MouseEvent):void{
                                                    MovieClip(this.root).nextScene();

  • Looping Footage Pauses On Last Keyframe Before Executing gotoAndPlay("loop");

    Hi,
    Using Flash CS5... I have a 6 second movie I need to continuously loop from the half-way point out, after it plays through once.
    I've used the gotoAndPlay("loop"); script to loop it... and it sort of works. But only sort of. Unfortunately, there's a distinct pause on the last keyframe before it loops each time, which destroys the essential flow of the animation.
    It can be viewed here: http://vivalasvacations.com/108/W2U/W2UComp06(LOOPED).swf
    The globe pauses after one revolution before it repeats.
    Does anybody have any suggestions as to how I might rid this project of the dreaded pause? Perhaps another method of looping is available which would render things more smoothly?
    Thanks,
    Steve

    Assuming your spinning globe is a MovieClip out of FLVPlayback, add ActionScript like the following just inside of it:
    this.SpinningGlobe.addEventListener(VideoEvent.COMPLETE, completeMovie_handler);
    SpinningGlobe.play();
    function completeMovie_handler(event:VideoEvent):void {
       event.currentTarget.seek(0);
       event.currentTarget.play();
    Where SpinningGlobe is the name of the above MovieClip instance.
    If you are exporting for Flash Player 10.2. see this thread.
    UPD: Nope. I was playing around with it for a while, an abrupt pause at the end of the movie is always here. It's almost unnoticeable on a thumbnail-like frame size I used to exploit, but becomes prominent once the frame size increases. Therefore, I would be interested in a solution as well.

  • Interactive Environment - Animation + gotoAndPlay

    Hello,
    I'm having some difficulties with an interactive flash movie I'm trying to create. I have a 'shop front' graphic that I created for my website. This is one in a number that I have completed, and the others I have succesfully animated in Flash. The basic idea of the shops are to give the user the ability to rollover an item, have a large version of the price tag appear (and disappear on roll out) and turn the item itself into a link (an invisible button on top of it) to a thread on the forums that gives further details about the item. I have done this with a previous shop and attached the .swf so that you may better understand what I mean. (Note that it still has some issues with the price tag rollover, which I intend to fix.)
    I have this new shop that I would like to incorporate new animation into. I've also attached the .swf (note if you need the .fla to further see what my project looks like I can get that to you - it just won't allow me to upload it) and it might be easier to follow my explanation if you view this. The graphic consits of two sets of scales and a cauldron. First off, I would like the cauldron's ladle to move continuously, from the point of the movie's loading. However, I also have animated the golden scales on the bottom shelf to dip down depending on which dish the user rolls over. I did this in a separate movie (which I also attached) and imported it into my shop front movie. I wanted the same rollover animation action to happen in this bigger movie, however I encountered difficulties. I am very much a learning Flash user and I can't comprehend the issue... but I did include the individual frames of the golden scale movie in the shop front movie so that it could still work.
    However, my problem is that now, when I rollover the scales, the cauldron ladle will move or change position while I am rolled over the scales. This is because I am using the gotoAndPlay command to navigate throughout the different parts of the movie, so that I could animate the two sets of scales.
    I hope this all makes sense. Could someone please tell me an easier way to have the scales animated (and still be able to rollover and have a another image appear (the price tag) while it is animating) and also the cauldron ladle stirring the entire time?
    Thank you so much, it is very much appreciated!
    -Austin

    I'm sorry to double post - I was just really hoping someone would be able to help me with this issue. It's quite frustrating and I am sure someone out there has the answer. I would really appreciate any help you can give.
    Thank you!

  • How to work with scenes, "gotoandplay" & movieclips?

    Hi!
    I've got a big problem when I'm working with movieclips,
    scenes & "gotoandplay"-command.
    Problem is, that I've a game, where you can move movieclip
    (player) with keys, so all those "gotoandplay-commands" must be
    within movieclips. So, I have tried to use
    "_root.gotoandplay();"-command, but when the second scene is
    playing, and that code is being used, the whole thing skips to
    scene 1 (main, the first one...), and starts to play from there...
    So, I suppose, that that "_root", isn't the right thing to be
    in there, but what code would work?
    This is my schoolwork, so I'd need quick answers... Thanks.
    Btw. Sorry my bad English

    using _root is fine. the problem is you need to use frame
    labels, not numbers. so, label your frames needed for navigation
    and use those labels in your goto methods.

  • Play button AS2 not working need help please!

    Hi,
    I have an AS2 project with two scenes, Scene 1 is has a pre-loader and Scene 2 has an embedded .flv animation from after effects with some other basic tweened shape layers and masks. I've used the Components UI and dragged a "Replay" button to the last keyframe with a seperate actions layer with the following code:
    stop();
    Replay.addEventListener(MouseEvent.CLICK, replayMovie);
    function replayMovie(evt)
    gotoAndPlay("Scene 2",1);
    I'm a beginner in Flash and have been following instructions off the net but I can't get it to Replay the movie when the button is clicked, it does nothing
    any help will be appreciated.

    Hi,
    I would not reply on the scene naming thingy if I were you. IN the pat I have had the very same problem and found that using
    _root.gotoAndPlay(frameNumberHere); works a lot better.
    ALSO
    if your scene 1 has 10 frames in it and your want to gotoAndPLat the 1st frame of your second scene then use:
    var number_of_Frames_in_1st_scene = 10
    var frame_I_want_to_go_to_and_play_in_my_second_scene_is = 1
    var frameNumber = number_of_Frames_in_1st_scene + frame_I_want_to_go_to_and_play_in_my_second_scene_is;
    _root.gotoAndPlay(frameNumber);
    dont forget the _root.

  • Need help with Adobe Flash Professional! Somewhat urgent!

    In Adobe Flash Professional, How Can I Split The Frames Of An Animated Symbol That Are Placed On The Seed Timeline Without The Symbol Restarting Its Entire Animation After Each Split? I have looked up many online tutorials and none run into this problem.

    My original response stands.  If you want to stop a timeline animation you need to implement a stop() command.
    If you need the animation to start/restart at a specific point then you use a gotoAndPlay() or play() command depending on where that starting point is relative to where you currently are on the timeline.

  • Need Help with ACTIONSCRIPT for Interactive Music Video

    I am trying to create an interactive music video in After Effects and Flash.
    The concept is that while the music video is taking place the user can  decorate the hair of the woman with any of the objects they select.   There will be predetermined animations and destination spots but the  user can choose whatever objects they select to be delivered to the  predetermined spot.  I need to figure out how to let the user to select  an object that will become part of the animation.  I created a PDF  Roughly explaining what I am trying to do.  If anyone can help me I'd be  very grateful as I am more versed in After Effects, I don't know  ActionScript well enough to execute what I am trying to do.
    Below is a rough example of what I am trying to do.  There will be a music video of an animated woman singing.  As she is singing the user will be able to click any of the objects , below the numbers 1-10.  Below it is illustrated that the user wants to press the blue number 2.  If the user presses the 2 the 2 will animate in the mouth of a bird to a predetermined pre-animated spot.  I assume I need to send a movieclip to a blank  holder on the timeline and use a gotoAndPlay() action ???  I am not well versed in ActionScript so any advice would help
    Now whatever number (movieclip) the user chooses next needs to be placed in another blank spot in the timeline? Below the user selcts the Pink 5.
    If the user just wanted to Place two "Blue 2's" then the "Blue 2's" would follow the same animated path and end up at the same predetermined space.
    If the user selected just 5's and 7's they would go to the predetermined preanimated paths
    How would I go about writing the Actionscript for this?

    Look, I hope you don't have false expectation that by knowing one piece of AS capabilities you will be able to accomplish your task.
    If I say that the code for placing one MovieClip into another is:
    clip1.addChild(clip2);
    will it make any difference in terms of implementation?
    Also, you say "select." This may mean a lot of thing: click, drag and drop, mouse down, etc. I am saying that implementation tightly depends of definitions that you give.
    I don't know the extend of your AS skills, so it is not easy to figure where to start helping. Also, forum, perhaps, is not the medium where someone will write a lot of code for you. It is good for getting answers to very specific questions and solutions. This is when you have some code in place already.
    What I would suggest is to start developing a very rough concept - no video, no birds, no numbers - just a static background image of the person you have in your first post. If you advance to an application that will allow user to select a square, place the square into another one - it will be a good start.

  • Frame names and how to invoke them

    What would you have to do to have something happen once a
    movieclip reaches a particular frame?
    I already got the answer to that question in a
    previous
    topic in case that something has to happen when the movieclip
    ends, but say you want to have something happen when the playhead
    reaches frame called, say, _now?
    I can think of a way (involving the clculation of the ratio
    between _currentframe and _totalframes) but, isn't there a simpler
    -and more precise- way, namely, invoking the frame by its name? How
    would that be done (if possible)?
    NOTE: I am assuming that adding code to the movieclip's
    timeline (instead of adding it to the main timeline) is a bad
    practice and should be avoided. Am I right at that?

    You can only target frame labels using the gotoAndPlay or
    gotoAndStop commands. If you want to detect whether a movieclip is
    on a certain frame, you could use the _currentframe to detect the
    frame number (no strings), or you could set a variable on the
    movieclip timeline, i.e. frameName = "_now", and then check for
    movieclip.frameName.
    Cheers,
    FlashTastic

  • Please help me resolve this [VERY EASY]

    Basically, I wish to click the right arrow key and for the images to flip through as you can see in the fla file provided. I control the count using and array and I am using a gotoAndPlay type method, when I play it through it plays fine however when I ask for it to play again it refuses to play again and just shows a blank screen..

    It was the problem with the loader,

  • Strange motion tween problem

    So I have been making an animation to a voice over for a project. Comes in at about 2000+ frames with each animations different "scene" location split into 16 layers.
    If I play the entire movie from start to finish my 2nd to last "scene's" motion tweens play really fast and repeat randomly.
    If I use a gotoAndPlay to the frame where this "scene" starts the motion tween plays as intended.
    The problem "scene" is setup like all my others with the "scene" being in its own movieclip on the main timeline, and then nesting other movieclips inside it. When I remove the tweens from the nested movieclips there is no movement issue, but obviously there is also no movement which I need.
    My fix so far has been to add a goToAndPlay on the first frame of the problem "scene", eg "gotoAndPlay(1895); above frame 1895" which plays the tween correctly but makes my audio stutter when it hits that frame. So is not exactly the desired effect.
    Note: when I say "scene" I don't mean flash scenes more taking about the different shots/locations of my animation.
    I've searched google for hours to try find a similar issues with no success. So really do appreciate any help or ideas from some more experienced flashers

    You're trying to have different slices fade in? If you just
    want the image,
    as a whole to fade in, import it and convert it to a
    MovieClip and fade in
    the clip.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Targeting the main timeline

    Trying to make the switch from AS2 to AS3 and like many
    before me, becoming confused.
    I've laid out three movieClips on my main timeline (named,
    "main") and spaced them five frames apart, nice and tidy, like I
    like to do. Each frame on the main timeline containing a movieClip
    has been given a unique frame label. My problem is, I want to have
    the movieClips jump to the next targeted movieClip on the main
    timeline after clicking a button, or upon entering the last frame
    of its predecessor, in some cases. In AS2 the was easy to do this
    was by using the gotoAndPlay function and targeting to the_root
    timeline. Now I can't figure out what to do. I can make any button
    inside a movieClip target a specific frame within that same mc, but
    cannot make a jump to the main timeline to play the next movieClip.
    What am I missing here? I'm a noobie at AS3 and fumbling my
    way forward. (should be obvious now) Is there a simple way to refer
    back to the main timeline, which is only one level up? What am I
    missing?
    Here's as far as I got with the AS3 code within the mcs:
    stop();
    cont5_mc.addEventListener(MouseEvent.CLICK, onClick2);
    function onClick2(event:MouseEvent):void
    trace("test");
    cont5_mc.buttonMode = true;
    The trace function runs true so it's a matter of telling the
    player how to get to the main timeline and frame label.
    TIA for your help, all you flashy genius . . . Speak to me
    like I am a three year old. -grin-
    thokitts

    kglad:
    Thank you for your instant reply. I see you sent it out last
    night. Really appreciated. Got my button in movieClip1 to refer
    back to movieClip2 on the main timeline with your help but now am
    presented with the issue of having the last frame of movieClip2
    automatically taking the viewer back to the main timeline to begin
    playing movieClip3, located on frame label "gsm".
    Again, I know this should be easy, but conceptually I am
    having a problem with how to do this. I don't have a button to
    attach the AS3 to and this new syntax is confusing to me. Nor do I
    want this to be a button based decision on the viewer's part. How
    do I attach this automatic jump back to the main timeline, frame
    label "gsm"? By an enterFrame event, which seems old school AS2? or
    stage.addEventListener? Is enterFrame even the way to do it
    anymore?
    Lynda.com tutorials are great but I'm struggling with this.
    TIA
    Thomas

  • Error 1158 "missing left brace"

    the following is my code. as you can infer from it's
    simplicity, I am inexperienced.
    import flash.events.MouseEvent;
    import flash.events.IEventDispatcher;
    fatmax.addEventListener(MouseEvent.MOUSE_OVER,extend);
    function extend(event:MouseEvent)void:
    trace("extended");
    the compiler gives the error of: 1158: Syntax error: missing
    left brace ({) before the function body.
    Yet, as can be clearly seen, there is a left brace.
    also, i do not intend for this to be void, but am just trying
    to get the button to work right now. When I later want it to play a
    motion tween that is on a different layer, how do I do that?

    Hi,
    import flash.events.MouseEvent;
    import flash.events.IEventDispatcher;
    fatmax.addEventListener(MouseEvent.MOUSE_OVER,extend);
    function extend(event:MouseEvent)
    :void
    trace("extended");
    You can then use the gotoAndPlay / myMovieClip.gotoAndPlay
    function.

  • Manage the mc timeline from the main

    Hi guys,
    I need to use gotoAndPlay with a timeline situated within a MC. So, how can I identify this timeline from the main one?
    P.S. could anyone advise me a good As 3.0 manual?

    Assign an instance name to the mc via the properties panel.  Let's say you name it "mc"... then to command that timeline from the main timeline you would use: mc.gotoAndPlay(?);

  • Slideshow w/ timer, navigation problem (once clicked timing off)

    I have a AS3 flash slide show that uses the timer method with a wait() function to change slides.  So the preloader is on frame one and the first slide is on frame two and the second slide is on frame three and so on.  At each slide frame there is a wait(7) statement so that the swf moves ahead to the next frame every seven sec. When I create a nav element that uses the gotoAndPlay function to target each frame, everytime the nav is clicked and goes to the corresponding slide the timing of the slides is all messed up. 
    Can anyone help me by suggesting a solution to this?  I may be nieve but it seems that once the button in the nav is clicked the timer keeps going on the slide the user was on when the nav was clicked.  How can I clear the wait() timer on click?  When I just add a remove.EventListener to the button the function in the frame is not available to the button though they are both in the same frame.
    Below is the wait() I am using in the root stage timeline:
    function wait(duration:Number) {
        stop();
        var timer:Timer=new Timer(duration*1000,1);
        timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerComplete);
        timer.start();
    function onWaitTimerComplete(e:TimerEvent):void {
        e.target.removeEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerComplete);
        stage.removeEventListener(Event.RESIZE, onStageResize);
        play();
    Below is the code for the click inside the movieClip button:
    b1.addEventListener (MouseEvent.CLICK, onClick);
    function onClick( event:MouseEvent):void
    MovieClip(root).gotoAndPlay(2);
    THIS PROJECT IS LOCAL SO NO LINK AVAILABLE

    Look further int the Timerclass to see what other methods you can make use of.  It has a reset() and a stop() method that could get you what you want.  One thing you will probably need to do though is to decalre the Timer outside of the function so that it has scope outside of the function so thaat you can have other functions' code control it.

Maybe you are looking for