A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: gotoAndPlay script not working

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    5

    gotoAndPlay script not working

    Hey hey.

    So here's my problem. I'm building my first actual flash site. I've had a lot of experience in other aspects of flash...just not a lot of scripting. My scripting attempts have been successful up until now. I have a button which I want, on release, to gotoAndPlay a different scene, first frame which I have named "about". This is the script I entered.

    on (release) {gotoAndPlay("about", "1");
    }

    But, whenever I test the movie, it just...well...doesn't work. No error messages come up or anything...it just doesn't prompt the new scene. Any idea's why this might be? I'd really appreciate any help!

  2. #2
    Senior Member donaldparkerii's Avatar
    Join Date
    May 2005
    Location
    San Diego
    Posts
    616
    If I were you I would try to stay away from scenes. With that code it is tryint go to to "about" in the current scene

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Posts
    5
    Well it allows me to specify whether i'm choosing a scene or just a frame. But what are my other options...I can't have that much info all in one movie clip, you know? I'm eventually going to need to know how to properly navigate between scenes.

  4. #4
    Junior Member
    Join Date
    Jul 2006
    Posts
    27
    i hear you, i asked the same question last week, i never got an answer...maybe theres no way to do it?

  5. #5
    Junior Member
    Join Date
    Feb 2006
    Posts
    5
    Odd, my friend suggested using this method over the phone the other day, so I'm assuming it can be done. I've been trying all day to figure out why and find a way around it but I'm stuck.

  6. #6
    Junior Member
    Join Date
    Jul 2006
    Posts
    27
    well if you happen to find out please let me know

  7. #7
    Senior Member donaldparkerii's Avatar
    Join Date
    May 2005
    Location
    San Diego
    Posts
    616
    If I were you I would copy all the frames for what ever is passed the first scene, and past them into a new fla file and publish that. it will save you from running into problems later on. Also more people will be able to help you with your questions that way.

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    5
    How can I navigate from one flash file to another with a button script?

  9. #9
    Senior Member
    Join Date
    Oct 2003
    Posts
    901
    I have a button which I want, on release, to gotoAndPlay a different scene, first frame which I have named "about". This is the script I entered.

    on (release) {gotoAndPlay("about", "1");
    }
    If you wanna continue using scenes here is the problem:

    you said the first frame of the new scene is named "about"

    However the code to play the next scene states that:

    on(release){
    gotoAndPlay("name of the new scene", "frame of the new scene");
    }
    so.. your code should be like this:

    on(release){
    gotoAndPlay("name of the new scene", "about");
    }
    goodluck

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    5
    No no, the scene is named "about". Sorry for the mix up. That was just bad sentence structure on my part... >.>

    I haven't named the first frame in the new scene. Thanks much for the attempt though. I really appreciate it.

  11. #11
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    I'm not to sure, (I don't use scenes). Try giving the first frame of the about scene a label name say about1, then just use gotoAndPlay("about1"); supposedly from what I hear, when flash compiles, it just makes it one big timeline. so if you just use a lebel, it should find it.

    this is striaght out of the help file, which I find amusing:

    Using scenes
    Using scenes is similar to using several SWF files together to create a larger presentation. Each scene has a Timeline. When the playhead reaches the final frame of a scene, the playhead progresses to the next scene. When you publish a SWF file, the Timeline of each scene combines into a single Timeline in the SWF file. After the SWF file compiles, it behaves as if you created the FLA file using one scene. Because of this behavior, avoid using scenes for the following reasons:

    Scenes can make documents confusing to edit, particularly in multiauthor environments. Anyone using the FLA document might have to search several scenes within a FLA file to locate code and assets. Consider loading content or using movie clips instead.
    Scenes often result in large SWF files. Using scenes encourages you to place more content in a single FLA file and hence, larger documents to work with and larger SWF files.
    Scenes force users to progressively download the entire SWF file, even if they do not plan or want to watch all of it. Your user progressively downloads the entire file, instead of loading the assets they actually want to see or use. If you avoid scenes, the user can control what content they download as they progress through your SWF file. This means that the user has more control over how much content they download, which is better for bandwidth management. One drawback is the requirement for managing a greater number of FLA documents.
    Scenes combined with ActionScript might produce unexpected results. Because each scene Timeline is compressed onto a single Timeline, you might encounter errors involving your ActionScript and scenes, which typically requires extra, complicated debugging.
    There are some situations where few of these disadvantages apply, such as when you create lengthy animations, which is a good time to use scenes. If disadvantages apply to your document, consider using screens to build an animation instead of using scenes.



    IMS

  12. #12
    Junior Member
    Join Date
    Aug 2006
    Posts
    6
    I think your problem is that you have the frame number in quotation marks. ("about", "1")

    this is not a scripting error, However you don't need to put the frame number in quotes. It won't read it as that. I hit the same problem last week. Take it out of quotes and that should work.

  13. #13
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    it is recommended practice to use frame labels
    give your target frame a label - say "movehere"
    and button action -
    Code:
    on(release){
    _root.gotoAndPlay("movehere");
    }
    the reason that this is recommended is because
    Code:
    gotoAndPlay("Scene1",frame or "label");
    will NOT work if used anywhere other than the main timeline (ie..from movieclip or loaded movie)

    hth

  14. #14
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Ok, I have got two scenes and to make things confusing i want scene 2 to play first, and then go to scene 1. this is the action script that i have tried...

    openbtn.onRelease = function (){
    gotoAndPlay("Scene 1", "newframe");
    }

    The First frame in the scene i am targeting is labelled 'newframe'.
    my button is obviously has an instance name off 'openbtn' and the script is in an actions layer on my main timeline of the scene that i want to play first.

    Any ideas??? cheers.

  15. #15
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    see my post above
    do NOT use the Scene name
    use the frame label ONLY

  16. #16
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Thanks for your reply, but I did already try it like that, and still no joy the button just doesn't redirect to the new scene...

    this is the AS i used which also didnt work...

    openbtn.onRelease = function (){
    gotoAndPlay("newframe");
    }

    any more ideas??

  17. #17
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    Not to worry, i realised that my AS was in the same layer as the AS i was using for another button on my movie. I simply moved the last action script that i posted and put it on a new layer and it worked fine, many thanks.

  18. #18
    Junior Member
    Join Date
    Dec 2008
    Posts
    5
    So now I have solved my problem of navigating from the first to the second scene using the method you explained, I wanted to include a third scene in between the other 2. I used exactly the same method, so basically just changed the frame label in the new scene and targeted it in the action script that I already had in my first scene.

    My button still goes straight to the scene it was going to before? Even after I have changed my AS. How can this happen? its navigating to a frame label that isn't typed in any where in my AS???

    here is the new action script which is navigating my button to frame label 'newframe' ...

    openbtn.onRelease = function (){
    gotoAndPlay("frametwo");
    }

    I obviously need it to go to the frame label that I have typed in above, which is in my new scene... Any ideas? Thanks...

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