AS If, else Help

geese, I just scripted a 5 MC nested deep deal MYSELF! I’m making a major break through in AS :<))). One glitch I have to fix:
I have a button with AS>
on (release) {
gotoAndStop(“infoscroll”, 1);
}

Is there a way to add some kind of if condition to this button so that IF the music IS OFF (it may be on or off) I can loadMovie again?
e.g., unloadMovieNum(140); —>User could choose to click the above button and leave with the movie off here<— loadMovieNum(“tab.swf”, 140);

LIKE, if it’s unloaded, load it else don’t load it kinda thingy??

let me know if you still need help here.

Yes, I still need help! I just don’t know how to write the if/else script. Thank you.

What do you use to know if the music is on or off?

The music is in the tab.swf. I am just using unloadMovieNum(140); to stop the music and loadMovieNum(“tab.swf”, 140); to start the music. I have this button:
on (release) {
gotoAndStop(“infoscroll”, 1);
}
On which I need to loadMovieNum(“tab.swf”,140); IF AND ONLY IF it is in the unloadMovieNum(140); state. I think my first post illustrates this best. Anyway the music is in the tab.swf. With a start and stop button and a vol. slider all of which are in a popup menu).
Note: the above button is on level 120, the tab.swf is on level 140.
Thanks!

When you load your movie, just set a variable to true

loadMovieNum(...) ;
musicIsPlaying = true ;

And the opposite when you unload it. That way you can test the value of that variable before you loadMovie :slight_smile:

Ok, I put:
unloadMovieNum(140); Frame 80, Actions layer
musicIsPlaying = false;

Then I put:
loadMovieNum(“tab.swf”, 140); Frame 1034, Actions layer
musicIsPlaying = true;

Then I put: On the button Actions
on (release) {
gotoAndStop(“infoscroll”, 1);
if (musicIsPlaying = false) {
loadMovieNum(“tab.swf”, 140);
}
}

This doesn’t work, what am I doing wrong???
Maybe I should tell you the load and unloadMovie Actions are in a MC. The above button is on the main stage. Is that the problem???

BTW, Many thanks for the help…I’m soooo close to done with this thing, been trying to resolve this for months.

if (musicisPlaying == false) instead of (musicIsPlaying=false)

On the second one, you’re telling it to assign the value on the right to the variable on the left. On the first one, you’re asking it if the value on the right is equal to the value on the left.

Thanks, but the == doesn’t make it work either, :<(((, I’m about ready to give up.

if you want a more specific answer, you need to post your file.

Otherwise, Ilyas was right on the money. The basic concept is that you will create a switch for yourself using a variable.

then, you will check the value of that variable to determine what you will do with it.

Post your file and we can look at it, it’s just faster than creating a whole example to demonstrate, although we will do that if necessary.

First: I just discovered that by going>Window and >View and unchecking Tools, Rulers, etc. you can reduce the size of a .fla file. I’m saying this for the benefit of others here who’ve also had trouble attaching large files in this forum.
I am attaching 3 .fla files (main.fla, video.fla and tab.fla) so you can see exactly my setup. Main.swf is level 0, video.swf loads in level 120, and tab.swf loads on level140.
THE PROBLEM: In video.fla, level 120 there are 4 red buttons. If a user clicks the 2nd button (from the left, i.e., “btnvideostop”{the music is off here}), THEN decides to click the 3rd button (from the left, i.e., “btninfostart1” to go to the next scene the music Does Not start again. Well, take a look. Thanks for all the help!!!

File 2

File 3 This is where I have linkage set to >myMusic01 in the library. Did not include any audio file in library due to file size, you can use your own audio file with the above linkage set.

Here’s the .swfs also.