I tried finding an answer to this problem a couple months ago and I got an answer, just not an answer that worked for my specific problem. Perhaps because I didn't explain my question well enough ... so I'm trying again.
I have three menu items (buttons A, B, C), each one showing you something different on the stage when clicked. It's the transition from menu item to menu item that I need help with.
You're viewing the contents of button A, you then click on button B and a segment of the timeline plays out (segment 1). At the end of segment 1 you are directed to the segment in the timeline that shows you the contents of button B.
Now, if you're back viewing the contents of button A and you decide to click button C, segment 1 will play out and at the end of segment 1 you are directed to the segment in the timeline that shows you the contents of button C.
It's that segment 1 in the timeline that I want to reuse but at the end of segment 1 you are directed to a different part in the timeline depending on which button you initially clicked. I kinda see a "if button B was clicked, go here", "if button C was clicked, go there" at the end of the segment in the timeline I want to reuse. I just don't know what the scripting for something like that is. I'm quite new with ActionScript.
Thank you very much for your help, but sadly my lack of knowledge with actionscript has stopped me yet again.
Using the scripting example you've given, when I test the movie I get this error, "Statement must appear within on handler". And of course I couldn't fix it.
Now, when I was attempting to solve this little error myself a thought occured to me. The script you've given is for when the movie reaches the end of segment 1. It redirects the play to the desired segment (segmentB, segmentA). What in this script directs the play to the beginning of segment 1?
You click on button B, it goes to the beginning of segment 1, plays, then at the end of segment 1 the play is directed to segmentB. If I had 5 buttons and you clicked on any one of them I want them to be directed to the beginning of segment 1 then at the end of segment 1, directed to segmentC or D or E.
I really appreciate all your help!! But I've run into a couple of snags.
The first snag is, when I press buttonB it goes to the beginning of segment1 nicely enough. But when I press buttonC it doesn't go anywhere, it doesn't do anything.
The second snag is, when I press buttonB, it plays segment1 but at the end of segment1 it jumps to the very beginning of the movie, not to segmentB.
I've checked the spelling of all my labels and there's no mistakes there. And for the first snag I checked everything for buttonB and made sure things were identical (except for labes and such) to buttonC. Below is what I've got on the frame, pretty much what you showed me ... though for my actual movie I do change the names accordingly ...
It took me about 20 to 30 times looking over your example and compairing it to my work, I retyped my script, I renamed labels, I cried .... but I got it!
It wasn't the scripting (or labeling) at all, I had copied that right. What it was, was that I had my buttons (A, B, C ...) each on their own layer! That's what was screwing everything up. All those buttons have to be on one layer for it to work ... and it does work lovely!
They dont have to be on the same layer, but they do have to already be instantiated on the timeline before you can assign any .onRelease (etc) methods to them. Having them on separate layers should not effect the functionality unless your code is being called to early based.
Really? Because when each button was on their own layer I did have them instantiated and it didn't work. Though I'm not too sure what you mean by "being called to early based".
And I think I may have spoken too soon with my previous post ... in a way.
When I got the script to work with my file it was after I deleted the other sceens in the movie. When I tried to get the script to work with all the sceens that's when it would jump to the very beginning of the movie after playing segment1. So, with my file that only had the one sceen (with the script working) I added a sceen in front of it and it went screwy again, the theDestination = "segmentB"; didn't work, play went to the beginning of the first sceen.
Alright! I think this is it! I added a bit more stuff to my movie to make sure it worked perfectly this time .... and it did! Wow, I can't thank you enough gparis!
Though I do have one tenny tinny question, and i don't know if it will be easy to explain or not. If it's complicated then don't bother.
Why does the addition of this. to gotoAndPlay(theDestination); make it work?
my guess is 'this' (or any timeline names like _level1.gotoAndPlay(x) etc..) is best practice for a reason. No path before the action makes the current timeline default, but it takes flash an extra step which made that single frame action not respond in time. That's only my guess.