A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: go to next scene button onrelease event - HOW?

  1. #1
    Junior Member
    Join Date
    Aug 2004
    Posts
    17

    go to next scene button onrelease event - HOW?

    Egads, I know this must be simple but I am having the hardest time with this! I am using FLash MX 2004 and am trying to institute a very simple procedure. I have 2 scenes and just want to have a button when clicked go to scene 2 and play. In Flash 5 this would have been SO simple for me, but Flash MX has really changed to way things are done and I am having trouble getting the correct syntax. I am obviously not an action scripting guru and rely on point and click syntax in the past.

    I finally found that many button features can be done through the Behaviors panel, but not an option to go to the next scene. When I checked Help and tried my own syntax through the action script panel I used this:

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

    I checked the syntax error feature and this is what was returned:

    ----

    **Error** Scene=Scene 1, layer=about button, frame=1:Line 1: Statement must appear within on handler
    goScene_btn.onRelease = function (){

    Total ActionScript Errors: 1 Reported Errors: 1
    ---------


    I know I am obviously doing something wrong. Shouldnt this be easier than it is? What am I missing?



    Thanks
    nicole

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    That message appears when you attach a script directly to a symbol and your script isn't formatted something like this:

    code:

    on(release)
    {
    }



    The style of scripting you are using is more appropriate for scripts which are attached to a frame in a timeline.

    Assuming you attached your script to the goScene_btn symbol, you could change your script as follows:

    code:

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



    ...and the error message should go away.

    Also, I would recommend against using scenes and using framelabels instead. I lot of folks here report trouble using scenes with actionscript, and Colin Moock recommends against it.

    code:

    on(release)
    {
    gotoAndStop("frame_label");
    }


  3. #3
    Junior Member
    Join Date
    Aug 2004
    Posts
    17

    frame label instead of scene

    So, you're saying I should just go to a label instead of a frame? Can I still go to a label within a different scene or do I need to have all my labels and layers in the same scene?

    I have LOTS of layers and dealing within one scene will be very challenging. So can I just create a label within the second scene and have it go to that scene and play?


    Thanks for the quick response.

    nicole

  4. #4
    Junior Member
    Join Date
    Jul 2002
    Posts
    5

    Cool Watch out with different timelines

    If you are using buttons in a different timeline you'll need to use this code.
    _____________________


    on (release)
    {_root.gotoAndStop("sc2");
    }

    _____________________

    Then be sure to label the first frame of the scene you want to go i.e. sc2 and forget naming scenes. It will change to the scene that you want by the labeled frame. Sorry if something's bad in my english... I'm from Mexico.
    Mess with the best & get burned like the rest!!!

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