samedi 7 janvier 2017

Action script 3.0, keyboard event listener doesnt work once mouse event initiated

parts of my code on first frame

credbut.addEventListener(MouseEvent.CLICK, credin);
closecred.addEventListener(MouseEvent.CLICK, credout);
stage.addEventListener(KeyboardEvent.KEY_DOWN, begin);
stage.addEventListener(Event.ENTER_FRAME, aigameloop);

function begin(e:KeyboardEvent):void
{
    clearScreen();
}
function credin(e:MouseEvent)
{
    credits.alpha +=  100;
    closecred.alpha +=  100;
}
function credout(e:MouseEvent)
{
    credits.alpha -=  100;
    closecred.alpha -=  100;
}
function clearScreen()
{
    stage.removeEventListener(Event.ENTER_FRAME, aigameloop);
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, begin);
    credbut.removeEventListener(MouseEvent.CLICK, credin);
    closecred.removeEventListener(MouseEvent.CLICK, credout);
    nextFrame();
}

once in 2nd frame, this codes doesnt work anymore

stage.addEventListener(KeyboardEvent.KEY_DOWN, fly); 
function fly(e:KeyboardEvent):void { 
 theBird.y-=50; 
 theBird.play();
}

id share my project if yould want to see the whole scenario

Aucun commentaire:

Enregistrer un commentaire