flash as3 document class and event listeners
- by Lee
I think i have this document class concept entirly wrong now, i was wondering if someone mind explaining it..
I assumed that the above class would be instantiated within the first frame on scene one of a movie.
I also assumed that when changing scenes the state of the class would remain constant so any event listeners would still be running..
Scene 1: I have a movieclip named ui_mc, that has a button in for muting sound.
Scene 2: I have the same movie clip with the same button. Now the eventListener picks it up in the first scene, however it does not in the second.
I am wondering for every scene do the event listeners need to be resetup? If that is the case if their an event listener to listen for the change in scene, so i can set them back up again lol..
Thanks in advance..
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent; import flash.media.Sound;
import flash.media.SoundChannel;
public class game extends MovieClip
{
public var snd_state:Boolean = true;
public function game()
{
ui_setup();
}
public function ui_setup():void
{
ui_mc.toggleMute_mc.addEventListener(MouseEvent.CLICK, snd_toggle);
}
private function snd_toggle(event:MouseEvent):void
{
// 0 = No Sound, 1 = Full Sound
trace("Toggle");
}
}
}