A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Multiple gotoAndPlay don't work

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    1

    Multiple gotoAndPlay don't work

    Hi.
    I'm new in Flash and I'm on my first project.
    I have created a Scene with a menu on the left side. This menu consists of 5 buttons with names "Step 1", "Step 2", "Step 3", etc.

    When scene starts, I have set the Step 1 to begin playing automatically.
    After that, user can press any of the menu buttons, so he can go to the step he wants.

    My problem is that when Step 2 ends, these menu buttons don't work.
    Neither when Step 3, 4 and 5 end.
    Only when Step 1 ends, the menu buttons work fine.

    I have the following ActionScript code on my project:

    Code:
    HomeButton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_10);
    
    function fl_ClickToGoToScene_10(event:MouseEvent):void
    {
    	MovieClip(this.root).gotoAndPlay(1, "Scene 1");
    }
    
    button_5.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);
    
    function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
    {
    	gotoAndPlay("Step 2");
    }
    
    button_6.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);
    
    function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
    {
    	gotoAndPlay("Step 3");
    }
    
    button_7.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);
    
    function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
    {
    	gotoAndPlay("Step 4");
    }
    
    button_8.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_6);
    
    function fl_ClickToGoToAndPlayFromFrame_6(event:MouseEvent):void
    {
    	gotoAndPlay("Step 5");
    }
    
    button_9.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_7);
    
    function fl_ClickToGoToAndPlayFromFrame_7(event:MouseEvent):void
    {
    	gotoAndPlay("Step 6");
    }
    Thank you in advance.

  2. #2
    Junior Member
    Join Date
    Dec 2012
    Posts
    9
    based on the info you provided.. my first thought is that you maybe only have that code on step1.
    if you go to a new frame.. you need to put code there as well... or turn it into a function...

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    106
    I agree with skedman that it could be an issue of the location of your code, but my solution would be slightly different. For a menu, where you are navigating around the timeline, it is best to have a single keyfame that is as long as the timeline with the code written once, instead of putting the same code on multiple keyframes.

    I would also suggest giving your buttons meaningful instance names:
    step2Btn instead of button_5
    step3Btn instead of button_6
    step4Btn instead of button_7

    Also give your functions shorter/more meaningful names:
    function step2clicked(e:MouseEvent):void instead of function fl_ClickToGoToAndPlayFromFrame(e:MouseEvent):void

    If you post source file I could help you out.

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