Fix flash focus to activate key clicks.

Problem with flash not working with key clicks. Using the JavaScript to focus the flash on load.

Question: How do I initiate the flash with out using the mouse click. For example I built a flash game utilizes the keyboard as the main controller and I want the flash game to listen for the key clicks to move the item in the game. The problem is when the page loads, flash does not have the focus so clicking on any key only controls the browser window and not the flash.

Answer: Use a JavaScript call on the body tag “onLoad” event like below to set the focus on the flash game using the flash embed id name like so:

<body onLoad=”window.document.flashIDname.focus();”>

flashIDname = The is the name of flash movie without the “.swf”.

Tagged : / / / / / / / / / /

One thought on “Fix flash focus to activate key clicks.

Leave a Reply

Your email address will not be published. Required fields are marked *