views:

22

answers:

2

Hi Guys,

I have a KeyboardEvent.KEY_DOWN event listener on frame 10 and on the first frame a button which when clicked takes you to frame 10, if you add gotoAndPlay(10); on the top of frame 1 the event listener works fine, if you click the button to get to frame 10 you have to click somewhere in the frame before the event listener works..

Any ideas?

D.

A: 

You can use the stages focus property to set the keyboard focus to an interactive object.

stage.focus = stage;
TandemAdam
That did the trick!Thanks.
Dean Bayley
A: 

In addition to TandemAdam's suggestion of shifting focus, you can register your events at the stage level. For example, call stage.addEventListener(...).

EDIT: Posted this right before I read your comment, Dean Bayley. It seems like you're already doing what I suggested, and in that case I can't reproduce your problem--it works fine on my machine.

31eee384