I’ve got a flash movie which imports an external SWF.
I have some interaction inside the external SWF (WASD to move the star) AND in the container (O to change circle color).
Everything works on Chrome and Firefox, but not on Internet Explorer and this is giving me a headache.
Here is the test: http://clients.adrime.com/files/campaigns2/9785452187/38177/default.htm
Here the code for the interaction of the CONTAINER:
stage.focus = stage;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onoff);
function onoff(e:KeyboardEvent):void
{
if(e.keyCode == 79) //O
bulb.gotoAndStop(bulb.currentFrame == 1 ? 2 : 1);
}
Here the one of the EXTERNAL SWF:
this.addEventListener(Event.ADDED_TO_STAGE, added);
function added(e:Event):void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, tastiera);
}
function tastiera(e:KeyboardEvent):void
{
if(e.keyCode == Keyboard.A)
st.x -= 5;
else if(e.keyCode == Keyboard.D)
st.x += 5;
else if(e.keyCode == Keyboard.W)
st.y -= 5;
else if(e.keyCode == Keyboard.S)
st.y += 5;
}
What is that I’m missing?
The operating system and the web browser will process keyboard events before Adobe Flash Player or AIR.
For security reasons FLASH never is auto focus – otherwise stealing keyboard input would be a snap.
There is a official Javascript solution. You can also use SWFObject to embed your flash content.