Dynamically switching scenes in flash w/ actionscript
is it possible to control what scene the movie goes to based on which button the user clicked? I was thinking something along the lines of
user clicks button1,
as the actions for the button:
ON Click: set variable Sceneto = Monkey
goto and play scene 21 in current scene
monkey is the name of a scene
then in frame... say 35
how do i make it so that it goes to the scene that is in the variable defined above. can some1 plz help?
hehe
JeevesBond posted this at 09:44 — 8th August 2003.
He has: 3,956 posts
Joined: Jun 2002
Although I haven't done any Flash for ages I believe this is possible. Although it's a little easier than the method you've described...Unfortunately I'm at my day job right now so can't go in to Flash and check, I'll have a look tonight if I get time
a Padded Cell our articles site!
Megan posted this at 13:43 — 8th August 2003.
She has: 11,421 posts
Joined: Jun 1999
This is excactly how the navbar on my flash site works, if I understand what you're talking about. What it does is when the user clicks on a button, it plays a section in the current scene and then goes to another scene based on which button was clicked (if you look at it that's how the wipe in/wipe out works). I'll have to wait until I'm home to check the code for that, but I think it just sets a variable and then in the last frame it says got to and play (variable).
Megan
Connect with us on Facebook!
ianrules posted this at 15:12 — 8th August 2003.
They have: 74 posts
Joined: Sep 2000
that is exactly what im talking about....
*waits*
Megan posted this at 01:28 — 9th August 2003.
She has: 11,421 posts
Joined: Jun 1999
There could be a better way of doing this, but this is what I did:
This is in the button, setting a variable (in this case "samples") for the script to use later on. goto being the name of the variable.
on (release) {
goto = "samples";
gotoAndPlay (205);
}
Then this is in the last frame of the scene (since it goes to frame 205 and plays to the end)
if (goto == "websites") {
gotoAndPlay ("websites", 1);
} else if (goto == "samples") {
gotoAndPlay ("samples", 1);
} else if (goto == "about") {
gotoAndPlay ("about", 1);
} else if (goto == "resume") {
gotoAndPlay ("resume",1);
} else if (goto == "home") {
gotoAndPlay ("main page", 1);
}
That's it! Pretty simple. Oh, and be careful if you put your navbar in a symbol - you'll need to go _root or _parent (forget exactly) to go up to the main level before sending it to the next scene.
Megan
Connect with us on Facebook!
forwardtrends posted this at 02:00 — 11th August 2003.
He has: 52 posts
Joined: Feb 2003
or just do this..
make each section a different .swf file.
make a black (empty) movie clip on your main (nav) stage (Positioned in the top left corner of where you want your sections loaded) - name it loader.
put an action on each button like so (changing the name of "yoursection.swf" to the name of the section file for each corresponding button)..
---
on (release) {
unloadMovie("loader");
loadMovie("yoursection.swf", "loader");
}
---
bang your done - quick and painless - no need for extensive frameage.
make sure the sction file is exactly the size you want it (use masking and preloader to make it clean)
Aaron Elliott
forwardtrends.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.