0
votes

i am using this code to play my animation using my keyboard, but for some reason i dont understand, i need to click on the stage first to make it work whe it should work automaticaly, can anyone help me to fix this please?

var collage

collage=0

function gocollage1(e:KeyboardEvent):void

{

if (collage==0 && e.keyCode == Keyboard.RIGHT)

{

collage=1

myanimation.play();

}

}

stage.addEventListener(KeyboardEvent.KEY_DOWN, gocollage1);

1
The stage needs focus before it can capture key events for security reasons. You could create a reason for clicking the stage, a 'start' or 'accept to continue' for example. - dan-steel
Do you mean stage or swf? - Fygo
the stage needs focus, they've attached the eventlistener to the stage. They could essentially be the same thing, stage and swf..what do you mean? Someone needs to click the swf(stage) yes - dan-steel
i have to click anywhere in the stage to be able to use my keyboard - user3280636
The stage and the swf is not the same thing. Setting the focus to stage is not a big deal. Setting the focus to the swf is. - Fygo

1 Answers

0
votes

If you want to set the swf focus to the stage.

stage.focus = stage;