View Full Version : Menu Using Seperate Flash Files

01-16-2007, 08:57 AM
Hi All,

I need some advice, I have a 5 menu system in my Flash file, and to keep size down each element of the menu is a separate Flash file. So basically if "About" is pressed the about file loads onto the stage... The problem I am having is, when a menu item is pressed, let's say "About", I want whatever file has been loaded previously, I want it to fade out and then load the selected file... How could I do this? Once the menu is pressed I could easily make an as to fade the current movie out, but how would the file know what to load as the next item?

01-16-2007, 07:13 PM
Simple and effective... use a counter. here's how:

let's say you have 5 buttons, each will load a new content page on the stage. (about, home, etc..)

somewhere off stage make a dynamic text box with a var: loadCount Then define the variable in the scripts/actions layer in your movie:

var loadCount= 0;

now on each button you would put something like:

_root.loadCount = 0;

this will set the counter to zero when the button is pressed.

then add:

_root.loadCount = 1;

This will set the variable to 1. (note change the on(release) number for each button, so you have 1, 2, 3, 4, 5... but leave the on(press) set to 0 for all 5)

so in effect you haven't changed anything in your movie just yet, but if you test your movie you should see the text box show a 0 when it loads, then as you press and release each button it will change to the number and back to zero.. once at this point go back to your movie. make a blank screen for your stage (this will show when no button is selected, and will be the transition between buttons.)

Now you said you can make the fade yourself, so I will leave that to you, but all you need then is a couple if/else statements:

if (_root.loadCount==1){
gotoAndPlay (fade sequence for button 1);
else if (_root.loadCount==2){
gotoAndPlay (fade sequence for button 2);
else if (_root.loadCount==3){
gotoAndPlay (fade sequence for button 3);
else if (_root.loadCount==4){
gotoAndPlay (fade sequence for button 4);
else if (_root.loadCount==5){
gotoAndPlay (fade sequence for button 5);
else if (_root.loadCount==0){
gotoAndPlay (the blank image you made earlier);

Now you will have to tweak the if/else to suit your movie as this one won't do crap for you, but the concept is what you need.

Good Luck with that :D