Results 1 to 12 of 12

Thread: How to link a button to a scene in CS4 actionscript 2.0

  1. #1

    How to link a button to a scene in CS4 actionscript 2.0

    Im sorry to ask such an obvious question, and I genuinely have spent a long time trying to find the answer before asking.....

    Please could anyone point me in the direction of a tutorial which will explain how to link my button to another scene?

    Thankyou in anticipation

  2. #2
    Hi,

    If you haven't given names for your scenes and are using the default names of Scene 1, Scene 2, etc... then you can link to a scene and frame like so:

    Code:
    // Button 1
    on(release)
    {
        gotoAndStop("Scene 1", 1);
    }
    
    // Button 2
    on(release)
    {
        gotoAndStop("Scene 2", 1);
    }
    You can also use gotoAndPlay().

    Code:
    on(release)
    {
         gotoAndPlay("Scene 1", 1);
    }
    Or if you name your scenes/frames (recommended), you can use it like so

    Code:
    on(release)
    {
         gotoAndStop("About Us", "start");
    }
    WARNING: Scenes are notoriously cumbersome to work with!! Use carefully.

    Hope that helps?
    Last edited by Citiboy; May 31st, 2010 at 04:49 AM.

  3. #3
    Thank you so much, you are a darling MWAH xxxx

  4. #4
    Oven
    n/a
    posts
    Guest

    isn't working :(

    I have tried all the different methods of getting from Scene 1 to Scene 2 with the use of a button.

    This is the current cod i have in the button

    on (release) {
    gotoAndStop("Scene 2", 1);
    }

  5. #5
    Unregistered1
    n/a
    posts
    Guest
    Quote Originally Posted by Oven View Post
    I have tried all the different methods of getting from Scene 1 to Scene 2 with the use of a button.

    This is the current cod i have in the button

    on (release) {
    gotoAndStop("Scene 2", 1);
    }
    Check you are using AS2 and not AS3

  6. #6
    1,391
    posts
    Registered User
    Oven is using AS2 - Flash would not allow object attached code under AS3

    Oven: your code is attached to the button/mc instance (thus the 'on' handler) and therefore the scope of the method call relates to that instance - to get the main timeline to change scenes target _parent (if single depth) or _root if necessary(although not recommended) - as in:

    _parent.gotoAndStop( "Scene 2", 1 );
    _root.gotoAndStop( "Scene 2", 1 );

  7. #7
    TheCanadian's Avatar
    10,251
    posts
    Noo doot aboot it, eh?
    Quote Originally Posted by cbeech View Post
    Oven: your code is attached to the button/mc instance (thus the 'on' handler) and therefore the scope of the method call relates to that instance
    If it's a Button, the scope is of the timeline where it's attached.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  8. #8
    1,391
    posts
    Registered User
    holy crap - thanks for reminding me C - additionally, with some quick reading, i was even further off, because the answer is...

    from the Docs:
    You can use the scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.
    so you must make the declaration on the root timeline to navigate scenes, regardless of type:

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

    and when declaring in this manner, the scope within the Function body is *not* _level0 - it is the instance - but because were not referencing the scope by prefacing with 'this' , it does resolve to the global Function

  9. #9
    TheCanadian's Avatar
    10,251
    posts
    Noo doot aboot it, eh?
    You can use it on Buttons.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  10. #10
    1,391
    posts
    Registered User
    wth - i ran several test previously - and now sure as...

    dang it C - why do you always have to be right

    and what's with the docs - i swear, after moving to 3 - 2 is just so screwed up
    Last edited by cbeech; May 16th, 2012 at 11:55 PM.

  11. #11
    TheCanadian's Avatar
    10,251
    posts
    Noo doot aboot it, eh?
    Don't worry, I'm wrong frequently.
    Proud Montanadian
    We tolerate living and breathing. And niches.

    Name Brand Watches

    Maybe getTimer() or TweenMax is the answer to your problem . . .

  12. #12
    1,391
    posts
    Registered User
    LOL - thanks C - only way we keep improving right

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012