View Full Version : Go to Scene from inside MC
calibanter
January 29th, 2003, 02:24 PM
My structure.
I'm in a movie clip with buttons. The buttons start an animation that will play over top. The animation works. But I also want to go to a new scene (in the same swf) after that animation is finished.
So I have the following script attached to each of the buttons (inside an mc called "links"):
on (release) {
mynewscene = "studio";
tellTarget ("_root.closemain") {
gotoAndPlay("start");
// plays animation (in mc closemain)
//and set variable of mynewscene
}
}
Currently I have the animation in another movie clip (called closemain) and the animation works. But, at the end of the animation (in closemain) I want to gotoandplay another scene.
I need to accomplish two things to do this.
I need to set the variable from whichever button was pressed (in my mc "links") which I attempted to do in the code above with 'mynewscene = "studio"'
And then after the animation (in the mc "closemain") is finished I need to gotoandplay that scene (the scene indicated by the variable "mynewscene". So the code at end of my animation in closemain looks like:
gotoAndPlay("mynewscene", 1);
Well, obviously this doesn't work.
Two (and a half) questions:
1. Can I gotoandplay a scene from inside a movie clip (and, if so, how)?
2. how do I record my variable (mynewscene) from one movie clip and use that variable in another.
Thanks.
zao
January 29th, 2003, 02:43 PM
to play a frame inside the movieclip just do this simple piece of code.
on (release) {
_root.links.gotoAndPlay(start);
}
links being the name of your movie clip
lostinbeta
January 29th, 2003, 02:50 PM
Yeah, this is a bug in Flash unfortunately.
Something you can do and has been proven effective by 9 out of 10 flashers is this.
In the Scene and on the Frame you want to go to give it a Frame Label (right click and open the properties panel).
Then Target it like...
_root.gotoAndPlay("frameLabelName");
calibanter
January 29th, 2003, 03:57 PM
LostinBeta,
is there a way I can set this up to point to a different scene?
I think this works so long as it's within the same scene, but how about pointing to a framelabel in a new scene?
Thanks.
lostinbeta
January 29th, 2003, 04:31 PM
nono, that method works if your frame label is in a different scene as well.
I know I know, I couldn't believe it either. Electrongeek is the one that showed me that it really does work when the label is in a different scene.
calibanter
January 29th, 2003, 04:58 PM
Maybe I can simplify my problem.
I need a button that's inside a movie clip to:
1. play a different mc (I know how to do this) and then
2. goto a frame (number or label) in a different scene
It's the second part I don't know how to do.
I need the entire mc to play before going to the new scene.
Can I add sequential actions to the original button?
Or can I add the script to the second mc to go to a frame in a different scene?
My project is finished except for this last mystery. And I would be ever-so grateful. I would put the answer up on my fridge and praise the person who solved this, my most recent bane.
Thanks.
lostinbeta
January 29th, 2003, 05:00 PM
Well you don't HAVE to put the change scene code on a button ;)
You can put it on the last frame of your MC so when that last frame hits it will _root.gotoAndPlay("frameLabel")
calibanter
January 29th, 2003, 05:16 PM
LostinBeta,
That's what I did.
I added the unique frameLabel to another scene, i.e., "startstudio"
and I made sure I spelled it right. And I added the code above
_root.gotoAndPlay("startstudio") to the end of the mc
and it's not working.
So I tried just the code _root.gotoAndPLay ("startstudio") to the original button thusly removing that extra step and it still didn't work.
But I believe you. I believe that it should work. I believe that it usually works. I guess I'm that 1 out of 10 flashers who was unlucky.
But since I know that it should work and since I know that it works 9 times out of 10 I will play with this until it does work and thank you in advance for a solution that should sove all my problems. And eventually I will make it work. Thanks.
lostinbeta
January 29th, 2003, 05:42 PM
I will whip up an example .fla ;)
calibanter
January 29th, 2003, 05:45 PM
that's definitely more than I would expect from even a friend but I appreciate it so much.
eyeinfinitude
January 29th, 2003, 05:49 PM
Calibanter, take a look at this thread, there is a sample file for you to look at. Here is the link. =)
http://www.kirupaforum.com/showthread.php?s=&threadid=10784&highlight=button+inside+movieclip
lostinbeta
January 29th, 2003, 05:54 PM
Please don't mind the incredibly basic look, I just drew squares real quick because it focuses on how it works not how it should look ;)
The black square it the button, the blue rectangle is the movie clip.
After you click the black square the blue rectangle will tween smaller then when it hits the end of the tween it will go to the frame label in the other scene.
Note: My file is Flash MX. Flash 5ers won't be able to see it.
lostinbeta
January 29th, 2003, 05:54 PM
And you beat me EG ;)
eyeinfinitude
January 29th, 2003, 05:56 PM
wow finally I beat you at something...:-\
lostinbeta
January 29th, 2003, 06:00 PM
You have surpassed me EG... I must bow to you ::bows::
eyeinfinitude
January 29th, 2003, 06:01 PM
hahah :!:
calibanter
January 29th, 2003, 06:02 PM
wow, lostinbeta, that's exactly the structure I have and it (yours) definitely works.
I will take a look at mine more carefully and see if I can't find where the hiccup is.
And thank you electrongeek, I think I've got more than enough to go on to work this out.
lostinbeta
January 29th, 2003, 06:03 PM
Be careful about your frame label.
I have found that if you change the label and dont click on the stage, but instead just switch to the other scene it doesn't register the frame label so you have to go back and re-enter it.
Maybe this was the problem?
calibanter
January 29th, 2003, 06:29 PM
That's it!
I was testing scene and for some reason it wasn't flipping to the target scene (label).
But when I published the whole fla and tested it was working!
Yeah! What a relief!
I'm going to print your answers and Electrongeek's too and put them on the fridge.
And then I'm going to have a beer.
Thanks.
eyeinfinitude
January 29th, 2003, 06:30 PM
LOL :P
lostinbeta
January 29th, 2003, 10:01 PM
Enjoy your beer ;)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.