I will be having BG music on my site and will have a simple on and off button for it without a volume option. I want it to fade out when turned off, and fade in when turned on.
This is in the first frame of the actions layer:
musicOn = 1;
this.onEnterFrame = function() {
if (fadeIn01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume+5;
if (myLoopVolume>99) {
fadeIn01 = 0;
}
}
if (fadeOut01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume-5;
if (myLoopVolume<5) {
_root.myLoop.stop("myLoop01");
fadeOut01 = 0;
}
}
};
This is what I have to create the sound in a seperate frame:
musicOn = 1;
this.onEnterFrame = function() {
if (fadeIn01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume+5;
if (myLoopVolume>99) {
fadeIn01 = 0;
}
}
if (fadeOut01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume-5;
if (myLoopVolume<5) {
_root.myLoop.stop("myLoop01");
fadeOut01 = 0;
}
}
};
And this is what I have attached to the button:
musicOn = 1;
this.onEnterFrame = function() {
if (fadeIn01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume+5;
if (myLoopVolume>99) {
fadeIn01 = 0;
}
}
if (fadeOut01 == 1) {
_root.myLoop.setVolume(myLoopVolume);
myLoopVolume = myLoopVolume-5;
if (myLoopVolume<5) {
_root.myLoop.stop("myLoop01");
fadeOut01 = 0;
}
}
};
I will also attach a link to the file since it is too big to host I think.
HERE IS THE FLA
Thanks for any help!!
ALSO: I will be loading this movie into another as an external movie. Do I need to change all the _root identifiers to this? or _parent?