I have a loader loading an external .swf
In my external .swf I have this
this.addEventListener(Event.ADDED_TO_STAGE,addedToStage)
function addedToStage(event:Event):void {
if(gameStarted == false){
stage.addEventListener(MouseEvent.CLICK, mouseClick);
this.removeEventListener(Event.ADDED_TO_STAGE,addedToStage)
gameStarted = true
}
}
function mouseClick(event:Event):void{
this.gotoAndStop("title1")
stage.removeEventListener(MouseEvent.CLICK, mouseClick);
}
NOW When I go to the title 1 frame, everything is fine
BUT the title 1 frame brings you to title 2 and when that happens, the click event to go to title 1 comes back for an unknown reason.
I’ll post the code for the title 2 frame.
var titleMusic2:Title2 = new Title2()
musicChannel = titleMusic2.play();
stage.addEventListener(KeyboardEvent.KEY_DOWN, Keys2);
function Keys2(event:KeyboardEvent):void{
if(event.keyCode == 32){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, Keys2);
gotoAndStop("stage1")
musicChannel.stop()
}
if(event.keyCode == 13){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, Keys2);
gotoAndStop("stage1")
musicChannel.stop()
}
}
Why is the click event listener coming back? I ADDED_TO_STAGE being called more than once? If so is there another method?