View Full Version : click flash to activate in browser
ryrocks
May 30th, 2009, 06:23 PM
Hey,
I've uploaded my flash game to the web, when I view the page in any browser I have to click the swf file before I can use the keyboard functions. I can't seem to find a fix.
Thanks
TOdorus
May 30th, 2009, 06:53 PM
There is no fix, because it's no bug. The OS needs to focus on the swf first before it will recieve keyboard commands.
Sirisian
May 30th, 2009, 11:20 PM
This is remedied by making a "play" button. You see with that simple trick you force the player to click on the swf. :P
ryrocks
May 31st, 2009, 06:35 PM
This is remedied by making a "play" button. You see with that simple trick you force the player to click on the swf. :P
I had considered this, I though there might be a simple HTML fix.
Well I dynamically added a button onto the stage, when you click it the button child is removed. However, you STILL need to click on the swf in order to use the keyboard controls, I'm surprised the button didn't fix this!
Any suggestions?
TOdorus
May 31st, 2009, 06:43 PM
Sigh.
Switching to a browser that always focusses on a plug-in? If there was a fix, this would mean that every Flash-ad would immediatly get keyboard control. And what if several games are on the same page, which would get the keyboard?
ryrocks
May 31st, 2009, 06:51 PM
Yeah ok, I realise that now.
Sigh.
Anyway, I've fixed my latest issue of the user still having to click on the swf, even after they have pressed the button.
The 'button' has to be a movieclip, not a button. I even tried adding the code:
play_select_mc.buttonMode = true;
This has the same unfortunate result.
So this means that when the user hovers their cursor over the button, they do not get the 'hand' symbol. Does anyone know how I can achieve this?
glosrfc
May 31st, 2009, 06:51 PM
I had considered this, I though there might be a simple HTML fix.
Any suggestions?
http://www.htmlcodetutorial.com/document/_BODY_onLoad.html
<body onLoad="window.document.flashIDname.focus();">
where flashIDname is the name of the movie without the .swf
http://www.webwasp.co.uk/tutorials/b35-Tab/tutorial.php
Note the browser limitations with body onLoad
You might want to consider using one of the more modern methods of embedding an SWF into a HTML wrapper, e.g. SWFObject, which should solve the focus issue.
http://code.google.com/p/swfobject/
http://groups.google.com/group/swfobject/browse_frm/thread/365cf0bb729930b9/a5c02bcf7b1c8949?lnk=gst&q=focus#
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.