PDA

View Full Version : sound on/off variable


cricket5
09-21-2005, 05:15 PM
Hi,
I hope I can explain this in a non-complicated way...
I am creating a Flash projector. I am having music loaded into it from an external swf in another layer. I have set up a movie that contain buttons in an on and off state to load/unload the music swf file. When the music is playing, the sound button is in the on state and displays an animation indicating that it is on. When it is off, there is no animation. This sound control movie is nested within another movie.
The projector file has several scenes in it. I have set up a varible called "music".
var music;

What needs to happen is when the sound button is turned off the variable is set to "musicoff". When turned on the variable is set to "musicon".

The on state button is programmed like so:

ON STATE:
on (release) {
music = "musicoff";
gotoAndPlay("off");

}

OFF STATE:
on (release) {
music = "musicon";
loadMovieNum("music-soft.swf", 5);
gotoAndStop("on");

}

At the beginning of each scene in the projector file I have the following code:
if (music == "musicoff") {
this.silver.musicbutton.gotoAndPlay("musicend");
} else if (music == "musicon") {
this.silver.musicbutton.gotoAndPlay("on");
}

Where "musicbutton" is a movie nested within the movie "silver". "musicend" is the last frame in the off button state.

The problem I'm having is that if the music is not playing I want the musicbutton to go to the "off" state. If I click the button and stay in that scene everything looks as it should. However, if I go to another scene in my projector the button returns to the "on" state (though the music is not reloaded until the button is pressed).
I'm not sure if the variable is not being set, or if that actionscript is not telling the musicbutton to go to the off state, or what?
I hope this is not too confusing.
Does anyone have any ideas about this?

Thanks!

lelales
09-21-2005, 05:32 PM
I only say "don't use scenes" because I have seen people smarter than me say the exact same thing. Either place all scenes on one timeline and use frame labels, or load separate swf's for each scene.

I hope this solves your problem

cricket5
09-21-2005, 11:44 PM
For ease of design, scenes need to be used in this project. There's got to be a way to make this work. Why would Macromedia put scenes in Flash if they are not good to use?

lelales
09-22-2005, 12:04 AM
I recently updated a site for United Way and they used scenes effectively, yet I did not understand how they made the sound work.

The sound was loaded into a separate swf then loaded into the movie. I haven't tried to execute a sound or music file over several scenes but it should be possible.

that's all I know.

cricket5
09-22-2005, 02:39 AM
yeah, mine is set up so that the music is loaded into an external swf. The music loads and unloads correctly. But when going to another scene the music control button resets to the "on" position, even though the music is still off.
I have tried the variables listed above as well as putting the sound control button in the same movie as the music and it still does the same thing. Weird.
Are my variables set up incorrectly?