A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Another gotoandplay problem

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    6

    Another gotoandplay problem

    Can someone help me figure out what I am doing wrong here? I have 3 different frames and two buttons. You start on frame "Health", and there are buttons that are supposed to take you to "Definitions" and "Chart." Here is my code:
    Actionscript Code:
    this.btn_MedDef.addEventListener(MouseEvent.CLICK, goMedDef);
    this.btn_MedChart.addEventListener(MouseEvent.CLICK, goMedChart);

    function goMedDef(event:MouseEvent) {
        gotoAndPlay("health-def");
    }
    function goMedChart(event:MouseEvent) {
        gotoAndPlay("health-chart");
    }

    But what is happening is that when you click the button, it takes you to different frames each time you click. For example, you click the button to go to Definitions (btn_MedDef) and it does take you to that frame. But if you click it again, it takes you to Health. Click it again, and you're back at Definitions. The other button behaves the same way: click on "Chart" (btn_MedChart) and it takes you to Definitions. Another click takes you to the Chart. Another click takes you Definitions again.

    Any idea why it is behaving this way and how to fix it? Thank you!!

  2. #2
    Senior Member
    Join Date
    Mar 2000
    Posts
    116
    Try changing it to gotoandstop();
    Webpages:

    www.winningsolutionsinc.com

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    6
    Quote Originally Posted by @ View Post
    Try changing it to gotoandstop();

    Thanks - I tried this and it did stop the problem of it changing with each click, but now both the buttons go to the wrong screens (Definitions goes to Health, Chart goes to Definitions). I've checked the frames and the labels all seem to be correct (i.e. the Definitions frame is indeed labeled "health-def"). What could be causing this?

  4. #4
    Senior Member
    Join Date
    Mar 2000
    Posts
    116
    try not using a - in the frame label. just use healthDef and healthChart
    Webpages:

    www.winningsolutionsinc.com

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    6
    Quote Originally Posted by @ View Post
    try not using a - in the frame label. just use healthDef and healthChart
    Still not working

    The weird thing is that earlier in the presentation, I have the exact same thing - a screen with several buttons that go to different frames and it works just fine. I used the exact same code, just changed the button, function and frame names (I had dashes in the frame labels there too). I can't understand why it's working there but not here.

  6. #6
    Senior Member
    Join Date
    Mar 2000
    Posts
    116
    without seeing the source file, I really can't help you debugg this anymore than I have. There might be an issue with using the same instance of a button on the same layer, or you might be using scenes that are some how getting out of scope. if you can post up the source files, i will see if I can help you out more.
    Webpages:

    www.winningsolutionsinc.com

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