GotoAndStop is sometimey

I have a movie that uses a next and previous button.  The next button works the same on every page calling a function that uses next().  The movie continues until it is told to stop.  The previous button takes you directly to a specific frame in the movie.  When running through and testing, if I go forward a frame and then back to the beginning,  and then add a frame every time, it seems to work fine.  But if I go forward 3 times and back 2, or mix it up in any way, the previous button will only work once.  Then after that you can go forward as much as you want, but you can only go back once.
Here is my code below
Each frame that has a previous button has a unique function.
Thanks in advance for any help.
Anthony
stop();
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, Next);
Next_btn.addEventListener(MouseEvent.CLICK, Next);
Previous_btn.addEventListener(MouseEvent.CLICK, Disclosure2);
function Disclosure2 (event)
    gotoAndStop("Disclosure2");
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, Next);
    Next_btn.removeEventListener(MouseEvent.CLICK, Next);
    Previous_btn.removeEventListener(MouseEvent.CLICK, Previous);

Well I implemented all the changes.  And I still get the inconsistent performance.  Is this a bug?  Or am I just missing something?
My code now looks as follows:
stop();
stage.removeEventListener(KeyboardEvent.KEY_DOWN, Next);
Next_btn.removeEventListener(MouseEvent.CLICK, Next);
Previous_btn.removeEventListener(MouseEvent.CLICK, Previous);
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, Next);
Next_btn.addEventListener(MouseEvent.CLICK, Next);
Previous_btn.addEventListener(MouseEvent.CLICK, Disclosure2);
function Disclosure2 (e:MouseEvent):void
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, Next);
     Next_btn.removeEventListener(MouseEvent.CLICK, Next);
    Previous_btn.removeEventListener(MouseEvent.CLICK, Previous);
    this.gotoAndStop("Beginning");

Similar Messages

  • How can I have keyframes on one layer proceed while using the gotoAndStop function?

    I have a Flash presentation that allows me to pair videos with the slides using a nice piece of ActionScript. The presentation advances to the slide on the next keyfram when the viweer clicks the "next button" and the video for that keyframe (on a separate layer) begins playing.
    owever, I am now trying to pair two slides with the same video without having the video restart or requiring the viewer to click the"next slide button" I was hoping I could just turn the two slides into a video clip, convert it into a symbol and insert the symbol in place of the static slide, but nothing seems to happen. I'm wondering if the "gotoAndStop" function in the ActionScript is preventing it from playing.
    Any thoughts on how I can have the presentation be controlled by the next and previous buttons most of the time, but have the exception of one slide that changes on its own? The relevant (I believe) code is below.
    Thanks!
    Julien
    // FUNCTIONS AND LOGIC
    function fl_prevSlide():void
              if(slides_mc.currentFrame > 1)
                        slides_mc.gotoAndStop(slides_mc.currentFrame-1);
                        if(transitionOn == true)
                                  fl_doTransition();
                        if(pageNumberOn == false)
                                  slideNumber_txt.text = "";
                        } else {
                                  slideNumber_txt.text = String(slides_mc.currentFrame + "/" + slides_mc.totalFrames);
    function fl_nextSlide():void
              if(slides_mc.currentFrame < slides_mc.totalFrames)
                        slides_mc.gotoAndStop(slides_mc.currentFrame+1);
                        if(transitionOn == true)
                                  fl_doTransition();
                        if(pageNumberOn == false)
                                  slideNumber_txt.text = "";
                        } else {
                                  slideNumber_txt.text = String(slides_mc.currentFrame + "/" + slides_mc.totalFrames);

    Try this code. Replace FLVmovie with the instance name of your FLV & set the time to when the frames shoudshould advance.
    import flash.events.Event;
    this.addEventListener(Event.ENTER_FRAME, checkTime);
    function checkTime(e:Event):void {
          if (this.FLVmovie.playheadTime >= 15)  // This is the playhead time in seconds
              this.gotoAndStop("frame label or frame #");
              this.removeEventListener(Event.ENTER_FRAME, checkTime);

  • GotoAndStop not working like it should (AS3 / CS4)

    Hi everyone, I've recently started using AS3 in flash and it's giving me some troubles. Here's the situation:
    On my first frame on the main timeline I  use a gotoAndStop("home") command to go to my homepage which is on frame 45 and labeled "home".
    From frame 2 up to frame 44 there are multiple movieclips with animations and sound in them, which stop at frame 45.
    When I use the gotoAndStop() command in my first frame it seems to work but the sounds of my movieclips in the previous frames keep looping.
    I don't understand why this is happening, since my movieclips aren't even on frame 45.
    Anyway, here's some of my code.
    first frame on main timeline code:
    [CODE]
    import flash.events.MouseEvent;    
    this.gotoAndStop("home");
    [/CODE]
    below that code are my buttons.
    here's the code from one of the buttons I use.
    [CODE]
    function mouse_over(e:MouseEvent){  
    e.currentTarget.gotoAndStop("_over");  
    function mouse_out(e:MouseEvent) {  
    e.currentTarget.gotoAndStop("_up");  
    function mouse_down_center(event:MouseEvent) {  
    btn_center.gotoAndStop("_down");  
    gotoAndStop("home");  
    btn_center.buttonMode = true;   
    btn_center.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down_center);  
    btn_center.addEventListener(MouseEvent.ROLL_OVER,mouse_over);  
    btn_center.addEventListener(MouseEvent.ROLL_OUT,mouse_out);
    [/CODE]
    I've also tried putting "this." in the button code and making a variable out of "this" to then use that variable in the code. It didn't change anything.
    Any help with this would be greatly appreciated.

    Sorry for the somewhat late response, didn't expect people to respond this quickly.
    There are no sounds when I use stop() instead of gotoAndStop() so I guess that means my sounds are coming from the movieclips? Not sure if this helps.
    I looked into using the soundmixer.stopall() but the problem is that I also have a background music playing (which works perfectly by the way) so that code would stop my music as well.
    I guess I should look into loading my sounds via actionscript, do I do that from within my movieclips or from the main timeline frame?
    The problem is that I don't want my sounds to start right at the beginning of the movieclip animation.

  • Firefox 3.5.5 will not display gotoAndStop properly when a Mask is involved

    I've created a Flash CS3 animation that has a mask moving across a graphic to simulate a horizontal scrolling fade-in effect. I'm using ActionScript 3 to set a Shared Object and the gotoAndStop method to move to the last frame in the animation so it only plays the first time the user sees the website.
    However, in Firefox 3.5.5 the animation is not showing up properly when the page is reloaded. For whatever reason, the mask is acting as if it's never moved and therefore does not show anything after that point. In all other browsers the animation skips properly to the end, thus showing the correct end result.  It also works properly in the stand alone Flash player.
    I've posted this on the Firefox forums as well just in case it's something on Firefox's end of it.
    Anyone have any ideas on why this behavior is happening?

    I've been able to replicate this several times with a few different animations.  It seems that the problem lies with Firefox 3.5.5, however the folks on those forums seem to think it's a problem within Flash itself.  I'd appreciate an official inquiry/response as this is prohibiting me from using Flash in the capacity for which it's needed.

  • "A.swf" on level 0 to a "B.swf" on level 1 with an "gotoAndStop(5)????

    Has enybody an idea, how i can refer from a flash "A.swf" on level 0 to a "B.swf" on level 1 with an "gotoAndStop(5). I tried it with:
    loadMovieNum("B.swf", 9), gotoAndStop(5);
    and other variations. It didn´t work anytime. Has anybody an idea how it can work?

    If you are trying to tell the B swf to gotoAndStop(5) after it has loaded, you need to wait until it has loaded and you need to target it as well.  Look into using the MovieClipLoader class.  If you look at the MovieClipLoader.addListener section of the help documents it provides an example of how to listen for completion of loading.  After loading you need to target the loaded movie... just using gotoAndStop(5) alone is tagerting whatever timeline that code is in, not any specific object.

  • Memory Leak with GotoAndStop()

    I am trying to track down a solution to a memory leak within an embedded video.  If I embed a video on the timeline and then run gotoAndStop or gotoAndPlay to a specific frame every time the frame changes it takes in more memory until it crashes at about 1.7GB however if I run a straight play() on the same clip the memory usage remains constant.  I have also tried System.gc() as it is an AIR App and have tried unloadAndStop() with the embeded video being loaded into a Loader and neither can reclaim any memory.
    I am looking for a a way to resolve the memory leak or another way to be able to rapidly jump to specific frames of video as far as I know this is not possible with external flvs.
    Thanks
    Dave

    video is much like a .gif file.  if you start at frame 0 and jump to frame 30 it needs to redraw what it does nt have in frame 30  which means tellign it to start at frame 30 is the same as telling it to get all information from when it last changed which might be frame 27 to complete the frame of what should display on frame 30.
    this is why its slow to play backwards.  and best to play an flv forward.
    what i would suggest if you do not need video persay, would be to use png sequences.  but if your videos are long then i suppose it would be a greater advantage to keep it compressed.
    what is the quality as well of the video and its size and your frame rate?
    You mention that you are creating a 3d view, how is that?  do you use more than 1 swf ?
    I still think this does not sound like a play head issue, since the video is already compiled.

  • Buttons doesn't gotoAndStop

    Ok I have this code inside a symbol called Gallery:
    stop();
    ////Event Listener/////
    img1_btn.addEventListener(MouseEvent.CLICK, play1);
    closeimg_btn.addEventListener(MouseEvent.CLICK, closeIMG);
    ////Functions/////
    function play1(event:MouseEvent):void{
    gotoAndStop("csfairplay_frm");
    function closeIMG(event:MouseEvent):void{
    gotoAndStop("noimg");
    But when I click the "closeimg_btn" button, nothing happens, no errors but output says:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at tpr_fla::Gallery_13/frame1()
    at flash.display::MovieClip/gotoAndPlay()
    at tpr_fla::MainTimeline/navigationClicked()

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is not in the display list
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • GoToAndStop or Play on Frame Label with Video doesn't work?

    I have a video in a frame that corresponds with the label "eight".  i have a button on the timeline with the following code.  i've tried it both gotoAndStop and gotoAndPlay and it doesn't work.  thanks in advance for your suggestions.
    on (press) {
    gotoAndStop(eight);

    use:
    on (press) {
    gotoAndStop("eight");

  • About gotoAndStop function

    Hi Everyone,
    This is Vinay. Hope you all are doing well.
    I have a problem with my flash file. Can anyone tell me how
    can I use gotoAndStop function. Actually I have a Movieclip on the
    stage and inside that two buttons are there. What I want is if I
    click on the buttons it should take me to the frame one of the
    second scene. For this I used the below function on one of the
    buttons.
    on(press)
    gotoAndStop("sceneTwo", 1);
    But it is not working. Can anyone solve my problem?
    Thanks,
    Vinay

    clbeech,
    > I'd thought about suggesting _parent here though
    although
    > that also seems to only work 'sometimes' - and this must
    be
    > the reason why perhaps?
    It gets even more complicated with the use of on() and
    onClipEvent(),
    because event handler scope changes between the attach
    approaches and their
    dot notation equivalents. Compare this (on a button symbol
    directly in the
    main timeline):
    on(release) {
    trace(this);
    ... which traces _level0, with this (same button, different
    approach):
    myButton.onRelease = function():Void {
    trace(this);
    ... which traces _level0.myButton. Awesome, right? lol
    > does any path indication other than local, force the
    change to
    > the MC method? (which would explain a lot lol)
    I would have to study more to give you a definitive answer,
    but my hunch
    is that a lack of object reference -- that is, simply
    gotoAndPlay(), or the
    like -- results in the stand-alone function. In AS2, anyway.
    It would
    certainly result in the function (vs the method) if you
    publish prior to
    Flash Player 5.
    In contrast, the presence of an object reference -- e.g.,
    this.gotoAndPlay() or _parent.gotoAndPlay() -- results in the
    method as a
    matter of course. After all, you're invoking a MovieClip
    method on a
    MovieClip instance.
    In AS3, you only get the method, because most of these
    ambiguously
    "gray" duos are gone. And AS3 re-introduces the scene
    parameter. But I
    just had a conversation with kglad in another thread in which
    CS4 seems to
    ignore the scene parameter, even in AS3. Unfortunately, I
    haven't done more
    testing there either. If it's a bug, then I'll do what I can
    to file a
    report with Adobe.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Urgent gotoandstop question

    Please help out...
    I want to know how to use the gotoandstop (or gotoandplay),
    from inside a movie clip. I want it to got to a frame that's in the
    main timeline. which means it's outside the movie clip. it doesn't
    seem to work.
    I have this:
    stop();
    secs = 3;
    function me() {
    gotoAndStop('pic2');
    clearInterval(pauseInt);
    delete me;
    pauseInt = setInterval(me, secs * 1000);
    pic2 is the name of the next frame in the timeline, it works
    fine if I use it in the timeline, but if I get into a movie clip
    and put it there it doesn't work.

    use either:
    _level0.gotoAndStop('pic2');
    OR
    _root.gotoAndStop('pic2');
    OR
    _parent.gotoAndStop('pic2');
    PS. you don't need 'delete me;' clearInterval will stop the
    loop.

  • GoToAndStop problem in AIR but not in Flash Player 10

    Hi,
    I'm currently developing a login screen for users to acces my application.
    For the login I have 3 frames, frame 1 allows the user to view the assessor login form or the client login form. Depending on which button they select the function "gotoAndStop(frameNo)" is called with frameNo being either frame 2 for assessors login or frame 3 for clients.
    I also have a back to the home screen button which returns to frame 1 "gotoAndStop(1)".
    The issue I am having is that it returns to frame 1 but the contents from the previous frame (a movie clip) is still visible. This issue doesn't happen when running my applications in flash player 10.
    Could anyone help?
    Regards,
    Shaun

    Just ran into this issue myself. This came up while looking to see what's going on. I'm testing AIR for iOS and if I do a gotoAndStop(), the numbers all trace correctly, but it doesn't seem to actually re-render the asset on the correct frame. If I click and advance the frame, it updates and displays the correct frame.

  • Can't gotoAndStop ...what's wrong with this button code?

    Hi,
    I'm totally stumped as to why I can't navigate to another frame.
    I have put 2 days into this simple problem now and I'm ready to give up and go back to AS2.
    Please help!
    I'm using CS4; publish settings AS3, 10.0
    I have a button on frame 2 that should take me to frame 3 when clicked.
    (So far I've tried a hundred different ways but I don't get to frame 3...)
    Different things I tried...
    > Creating the button dynamically from the library...
    > Inserting it statically from the library on frame 2...
    > referencing the mainTimeline through a variable...
    > wrapping the gotoAndStop action in another function...(if placed directly on the timeLine the movie correctly goes straight to frame 3)
    > naming frame 3...
    > using 'nextFrame' instead of 'gotoAndStop'...
    etc..
    In most cases I don't get an error in the output panel and no compiler error either; it just doesn't work!!!
    (Just stays on the same frame after I click the button)
    Here's the code I think should work; but doesn't:
    function moveTo3 (event:MouseEvent):void {
        trace("button_clicked"); // always traces correctly; but movie does not go to frame 3 !!!
        gotoAndStop(3);
    f_btn.addEventListener(MouseEvent.CLICK, moveTo3);
    WHAT AM I MISSING HERE?
    Thanks in advance ...

    Hi Ned,
    I have to run out and don't have the time to deal with it right now but you're RIGHT.
    I do have an 'onEnterFrame' listener on frame 1 !
    It's doing some animation with a symbol and I don't think I removed the listener itself.
    I just set the object to null when it reached [alpha:0].
    THANKS!
    I'll check it out as soon as I can but I really think you got me looking in the right direction now.
    Thanks again,
    Connor
    (I'll post an update when I get back to it)

  • Error 1180 : undefined method stop and gotoAndStop

    Error 1180 : undefined method stop and gotoAndStop
    i don't know why
    Here ,, it's my code is file [.as] and i use as3
    package {
              import flash.display.*;
              import flash.events.*;
              import flash.text.*;
              import flash.utils.Timer;
              import flash.media.Sound;
        import flash.media.SoundChannel;
              import flash.net.URLRequest;
              public class MemoryGame extends Sprite {
                        static const numLights:uint = 5;
                        private var lights:Array; // list of light objects
                        private var playOrder:Array; // growing sequence
                        private var repeatOrder:Array;
                        // timers
                        private var lightTimer:Timer;
                        private var offTimer:Timer;
                        var gameMode:String; // play or replay
                        var currentSelection:MovieClip = null;
                        var soundList:Array = new Array(); // hold sounds
                        public function MemoryGame() {
                                  //soundBG.load(new URLRequest("soundBG.mp3"));
                                  //soundBG.addEventListener(Event.COMPLETE,loadSoungBgComplete);
                                  stop();
                                  StartBtn.addEventListener(MouseEvent.CLICK, clickStart);
                                  function clickStart(e:MouseEvent){
                                            gotoAndStop("startPage");
                                  // load the sounds
                                  soundList = new Array();
                                  for(var i:uint=1;i<=5;i++) {
                                            var thisSound:Sound = new Sound();
                                            var req:URLRequest = new URLRequest("note"+i+".mp3");
                                            thisSound.load(req);
                                            soundList.push(thisSound);
                                  // make lights
                                  lights = new Array();
                                  for(i=0;i<numLights;i++) {
                                            var thisLight:Light = new Light();
                                            thisLight.lightColors.gotoAndStop(i+1); // show proper frame
                                            thisLight.x = i*90+100; // position
                                            thisLight.y = 175;
                                            thisLight.lightNum = i; // remember light number
                                            lights.push(thisLight); // add to array of lights
                                            addChild(thisLight); // add to screen
                                            thisLight.addEventListener(MouseEvent.CLICK,clickLight); // listen for clicks
                                            thisLight.buttonMode = true;
                                  // reset sequence, do first turn
                                  playOrder = new Array();
                                  gameMode = "play";
                                  nextTurn();
                        // add one to the sequence and start
                        public function nextTurn() {
                                  // add new light to sequence
                                  var r:uint = Math.floor(Math.random()*numLights);
                                  playOrder.push(r);
                                  // show text
                                  textMessage.text = "Watch and Listen.";
                                  textScore.text = "Sequence Length: "+playOrder.length;
                                  // set up timers to show sequence
                                  lightTimer = new Timer(1000,playOrder.length+1);
                                  lightTimer.addEventListener(TimerEvent.TIMER,lightSequence);
                                  // start timer
                                  lightTimer.start();
                        // play next in sequence
                        public function lightSequence(event:TimerEvent) {
                                  // where are we in the sequence
                                  var playStep:uint = event.currentTarget.currentCount-1;
                                  if (playStep < playOrder.length) { // not last time
                                            lightOn(playOrder[playStep]);
                                  } else { // sequence over
                                            startPlayerRepeat();
                        // start player repetion
                        public function startPlayerRepeat() {
                                  currentSelection = null;
                                  textMessage.text = "Repeat.";
                                  gameMode = "replay";
                                  repeatOrder = playOrder.concat();
                        // turn on light and set timer to turn it off
                        public function lightOn(newLight) {
                                  soundList[newLight].play(); // play sound
                                  currentSelection = lights[newLight];
                                  currentSelection.gotoAndStop(2); // turn on light
                                  offTimer = new Timer(500,1); // remember to turn it off
                                  offTimer.addEventListener(TimerEvent.TIMER_COMPLETE,lightOff);
                                  offTimer.start();
                        // turn off light if it is still on
                        public function lightOff(event:TimerEvent) {
                                  if (currentSelection != null) {
                                            currentSelection.gotoAndStop(1);
                                            currentSelection = null;
                                            offTimer.stop();
                        // receive mouse clicks on lights
                        public function clickLight(event:MouseEvent) {
                                  // prevent mouse clicks while showing sequence
                                  if (gameMode != "replay") return;
                                  // turn off light if it hasn't gone off by itself
                                  lightOff(null);
                                  // correct match
                                  if (event.currentTarget.lightNum == repeatOrder.shift()) {
                                            lightOn(event.currentTarget.lightNum);
                                            // check to see if sequence is over
                                            if (repeatOrder.length == 0) {
                                                      nextTurn();
                                  // got it wrong
                                  } else {
                                            textMessage.text = "Game Over!";
                                            gameMode = "gameover";
    and i don't push any code
    at fla file
    why i got that help me plss
    that is my homework and i must send it today TT

    can you write how to use ?
    i write
    "import the flash.display.MovieClip; "
    still error ahhh
    i try to change extends MovieClip instead Spirt
    and not error stop(); and gotoAndStop Already
    but
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
              at MemoryGame/nextTurn()
              at MemoryGame/clickStart()
    i got thissssssss TT
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.Timer;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.display.MovieClip;
    that i import

  • Problem with NumericStepper and MovieClip's gotoAndStop

    I have a NumericStepper that increment/decrements the slides in a MovieClip called libMC:
    <mx:NumericStepper id="slide"
    change="{libMC.gotoAndStop(slide.value)}" value="1" minimum="1"
    maximum="{numberOfPages}" stepSize="1" />
    For some reason when I am on the last slide and try to go back to the
    second to last slide (either using the down arrow or entering the
    second to last page number in the textbox and hitting Enter on the
    keyboard), I still remain on the last slide. This problem ONLY occurs
    when going from the last slide back to the second to last slide. All
    other slide transitions work fine.
    Any ideas?

    use the trace() function to debug your code.

  • For statement for gotoAndStop plz help!

    Hi,
    NumberDots();
    var myvar
    function NumberDots():void
    for (var i:int=1; i<=5; i++)
    myvar = "btn"
    trace(i)
    myvar+i.gotoAndStop(i)
    trace("looped " + i);
    trace("myvar = " + myvar);
    I have this code and am trying to get the 5 btns on my screen to go to a diffrent keyFrame each
    first one to frame1 second to 2 and etc
    if u can help ill rly apriciate it
    thx pavel

    var buttons:Array = new Array(btn1, btn2, btn3, btn4, btn5);
    NumberDots();
    function NumberDots():void {
        for (var i:int=0; i < buttons.length; i++) {
        var frame:Number = i+1;
        buttons[i].gotoAndplay(frame);
    Put the buttons in an array and refer to array instead. In the array simply put the instance names of the buttons. in the order you want them to move (1,2,3).

Maybe you are looking for

  • Optical drive does not read CD's but DVD's please help!

    My disc burning read-out is: HL-DT-ST DVD-RW GWA-4165B when i place any type of CD in my optical drive, after a few seconds the drive ejects. When i place any type of DVD media in the optical drive it reads perfect. any one have a solutions please he

  • Spry Validation - using a valid state image

    Hello, I have been looking through Adobe labs and spry documentation but I cant seem to find a way to use an image as an indication of the valid state of a form. I have seen disscussions on this forum about using adobes labs sample. I have looked at

  • Tidy up scanned hand drawings

    Dear forum, I have several hundred TIF images at 1200 dpi+ which represent scans of hand drawings on parchment paper using pencil or ink-pen (.2mm or thereabouts) of 4000 year old cuneiform documents. The drawings were made over an extended period of

  • How many fans does the Macbook Pro late 2011 15 inch have?

    Helio I've been using my mac for about two years and always took it to maintanance. I want to know if this model has two fans or only one. I use an application called smcfancontroller which tells me there is two fans however the left fan is the only

  • I can't install MS Office 2011 on mountain lion

    Hi, I just installed Mountain Lion, I made a clean install of it so I needed to reinstall all of my programs including Microsoft Office 2011 for mac. The problem is that I bought only a key for the program. The process for installing was originally d