A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: gotoAndPlay won't work properly

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    22

    gotoAndPlay won't work properly

    Hi,

    For some reason, the gotoAndPlay command in one of my frames won't work properly (I think that's the problematic command, but maybe it's another one in the movie).

    Frame 1 consists of a button instance named "menu", which is a text reading "menu". When pressed, the animation starts playing and several menu options appear in a frame-by-frame animation, which lasts up to frame 7 where the movie stops.
    When the "menu" instance is pressed again, the playhead is released and the movie plays another frame-by-frame animation (from frames 8 to 16) of the menu options disappearing.
    So, in frame 16 there appears only the "menu" instance - just like in frame 1.

    All of the above works fine.
    What I want to do is tell the player to go back to frame 1 as soon as it reaches frame 16, so the menu can open up again when the instance is pressed.
    I put this code in frame 16:
    gotoAndPlay(1)
    and it seems to be working fine, but when I press the "menu" instance for the third time (meaning, after it has already opened up and closed one time), the movie starts playing from frame 8 for some reason.

    I've included the file itself - you can just try testing the movie to see the problem.
    Any advice would be greatly appreciated.
    Thanks!
    Attached Files Attached Files

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    function onButtonClick1(evt){
    	evt.target.removeEventListener(MouseEvent.CLICK, onButtonClick1);
    	gotoAndPlay(2);
    }
    Code:
    function onButtonClick2(evt) {
    	evt.target.removeEventListener(MouseEvent.CLICK, onButtonClick2);
    	gotoAndPlay(8);
    }

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    22

    It kind of worked, but not completely...

    Thanks! It fixed that problem perfectly, but kind of screwed up the other pre-existing navigation parts in the file...

    Take a look at the full file attached (test the movie)-

    1. Click the menu and select a certain menu item.
    2. Then, click the menu button again - you are directed to an animation that "reconstructs" the menu by placing your selected item back in its place.
    3. Select a different menu item - you're directed to a different animation that reconstructs the menu by placing your new selected item in its place.

    The problem arises when you select an item that you've already selected before and then go back to the main menu.
    When you do that, the playhead just goes to all kinds of different places on the timeline and reconstructs the menu with the wrong animations.
    I've spent hours double-checking the gotoAndPlay() commands in all the frames to make sure that they indicate to correct frames to go to - I've found no mistakes.

    The timeline might seem a bit intimidating, but once you test the movie you'll probably see what it's all about.

    Thanks so much again!
    Attached Files Attached Files

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Try this...
    Last edited by dawsonk; 09-14-2010 at 04:40 PM.

  5. #5
    Junior Member
    Join Date
    Sep 2010
    Posts
    22
    Thanks so much, it works perfectly!

    You're the best!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center