A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Button Go To Next Scene....HOW?

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    2

    Button Go To Next Scene....HOW?

    Hello all,

    I have what seems like a ridiculously easy question, but it has stumped me for the past 2 days...I finally decided to seek out help.


    I am working on a simple flash project, static scenes mostly...It's kind of like a Powerpoint presentation, really.

    Anyway, in Scene 1, I have some buttons which I want to lead to Scene 2, Scene 3, and Scene 4. However, I can't make the buttons work! I have tried this code:

    btn_1.onRelease = function (){
    gotoAndStop("Scene 2", 1);
    };


    It gives me these errors:

    1120: Access of undefined property btn_1.
    1067: Implicit coercion of a value of type int to an unrelated type String.


    And I wind up with a looping flash movie of scene 1 and scene 2, even though I put a stop() on the timeline of Scene 1.

    What am I doing wrong???

    Thank you!

    The Goz

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    First, you are either posting an AS2 question in an AS3 forum, or you are unaware that onRelease and other onSomethings have been replaced by addEventListener.

    Second, you are apparently putting this code in a scope where btn_1 is not defined. Where do you declare btn_1 and where is this code?

    Third, the two argument form of gotoAndStop needs the frame number or label as the first argument and the scene name as the second.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    2
    Yeah, I did figure out that I was using ActionScript 2. I didn't realise ActionScript 2 and ActionScript 3 use different coding.

    And yes, using the arguments I had them mixed up.

    So therefore, I figured out something that works for me. I used this code:

    stop();

    Btn1.addEventListener(MouseEvent.CLICK, nxtScene);
    function nxtScene(event:MouseEvent):void{
    gotoAndPlay(1, "Scene2");
    }


    It seems to be working now....But now I'm going to start messing around with making buttons that jump between scenes. So far, it seems simple enough as long as you change the function names so that they don't create duplicate instances.

    Thanks for the guidance, sorry for being such a n00b.

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