Hello,
I am currently writing a little fishing game just for fun. I made a menu screen and now my listeners don’t respond after i gotoAndStop() (unless I click, which is pointless).
Here’s my code:
This is frame 1
stop();
playButton.addEventListener(MouseEvent.CLICK,playOn);
function playOn(event:MouseEvent):void{
gotoAndStop(2);
}
This is frame 2
var harpMoving:Boolean = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN,boatMover);
stage.addEventListener(KeyboardEvent.KEY_UP, harpMover);
stage.addEventListener(Event.ENTER_FRAME, everyFrame);
function boatMover(event:KeyboardEvent):void{
if(event.keyCode == Keyboard.LEFT && Boat.x >= 0 ){
Boat.x -= 15;
}
if(event.keyCode == Keyboard.RIGHT && Boat.x <= 450 ){
Boat.x += 15;
}
if(event.keyCode == Keyboard.DOWN){
harpMoving = true;
if(Boat.Harpoon.height >= 290){
harpMoving = false;
}
}
//trace(Boat.x);
//trace(Boat.Harpoon.height);
}
function harpMover(event:KeyboardEvent):void{
harpMoving = false;
}
function everyFrame(event:Event):void{
if(harpMoving){
Boat.Harpoon.height += 10;
}
if(!harpMoving && Boat.Harpoon.height >= 1){
Boat.Harpoon.height -= 10;
}
}
And here’s a link to the .fla incase you want to run it and see:
https://bearspace.baylor.edu:443/Dan_Johnson/public/flashFun/goneFishin’.fla