View Full Version : Keeping track of loaded movies?
NitroLiq
March 26th, 2003, 12:59 PM
Does anyone know how to keep track of loaded MCs? I have a navigation system loading content MCs. The problem is, when I choose another nav button, I want it to (onPress) figure which clip is currently loaded then gotoAndPlay a frame label in that clip, which will play an exit animation and load the content area corresponding to the newly pressed button.
Someone on Flashkit suggested having the loaded content MC send a variable to the main time line to act as a kind of flag to say which section is active but I'm not sure how to go about doing this.
Any direction or help is greatly appreciated here.
Guig0
March 26th, 2003, 01:13 PM
place this code on the first frame of all of yours to-be-loaded movies:
_level0.loadedMovie="nameOfThisMovie";
now you have a variable (loadedMovie) that stores in a string ("nameOfThisMovie") the name of the loaded movie on your main movie (_level0) ;)
NitroLiq
March 26th, 2003, 02:17 PM
Sorry if I'm being dense here. So, let's say for example I put the line of code in 3 separate content swfs:
_level0.loadedMovie="news"; //content clip 01
_level0.loadedMovie="portfolio"; //content clip 02
_level0.loadedMovie="contact"; //content clip 03
Each content clip has two frame lablels called "enter" and "exit" situated in exactly the same place.
Okay, so lets say the "news" section loads when the root movie loads. So, now I have a variable named loadedMovie whose value is the string "news".
Now, in my main navigation I have 3 MCs acting as nav buttons. So, if I wanted to script the buttons to call the variable could I do something like this?
ex: portfolio button:
on (release) {
loadedMovie.gotoAndPlay("exit");
_root.contents.loadMovie("portfolio.swf");
}
My thinking is that on release, it's going to go to the exit frame label no matter which content clip is loaded and play the exit animation. Then load the appropriate swf file. Is this correct? Will it wait for "exit" to finish playing before loading up the next clip?
Guig0
March 26th, 2003, 02:55 PM
Oooh... i see...
nope, it won´t work that way. i tell you why:
on (release) {
loadedMovie.gotoAndPlay("exit"); <---this line won´t work
_root.contents.loadMovie("portfolio.swf"); <---even if the last line worked, with this line you load the next movie, but the previous won´t wait for that
}
the best way to do what you want is:
load all content mcs in the same level (lets say level 1), and on the buttons of the main movie place this code:
on (release) {
_level1.loadedMovie = "movieToBeLoaded";
_level1.gotoAndPlay("close");
}
and on your to be loaded movies, on the last frame place this code:
loadMovieNum(loadedMovie+".swf", 1);
just like these files attached ;)
Guig0
March 26th, 2003, 02:57 PM
hehe... change the loadedMovie variable to movieToBeLoaded... it makes more sense ;)
NitroLiq
March 26th, 2003, 03:46 PM
That's awesome! I'm still trying to get a grasp on what the code is actually doing, though...tying my head in knots. :sigh: as easy as it may be. Will this work the same if I'm loading the content swfs into an empty mc on the root timeline named content?
Button code:
on (release) {
_root.content.loadedMovie = "movieToBeLoaded";
_root.content.gotoAndPlay("close");
}
Last frome of a content clip:
loadMovie(loadedMovie+".swf", _root.content);
Guig0
March 26th, 2003, 03:56 PM
yep, it works!
and wich part you´re not understanding? it is more important for you to understand, therefore learn, than just get your movie to work ;)
NitroLiq
March 26th, 2003, 04:29 PM
I just got it to work with a target MC. Yay me! Heh.
What I'm not getting is the logical order of how the entire thing is working especially with the variable. Like how each individual part is communicating with one another. I want to get a grasp on this so I can figure out how to add to it...like once the button is clicked, not having the animation repeat when it's clicked again (when it's content clip is the current clip).
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.