views:

18

answers:

1

Hi, I've searched here and with Google but I can't find an answer to this. Our app uses the WebBrowser control to display SWF flash objects to users. This works fine with the mouse but some deployments only have a remote control with arrow keys. The problem is that when the Flash object loads

WebBrowser.Navigate("c:\mypath\myflashfile.swf");

the Flash object does not have focus so the arrow keys do not work. Pressing the Tab key on the keyboard gets the focus on the Flash object and then the keys work but this won't work with the remote control. Anybody any ideas on how to get the Flash file to accept arrow key control once it is loaded?

Thanks.

A: 

I do not know Flash at all, but I would guess there is some kind of event that you could handle in Javascript that indicates that the Flash object has loaded. For example, in Silverlight you can provide a JavaScript "callback" that is called once the Silverlight control is loaded.

Here is some code from my blog that shows what I mean in the case of Silverlight, hope you can translate this to a Flash equiv.

1- Give the element in the web page an ID

2- Pass the ‘onLoad’ parameter on the Silverlight application assigning a JavaScript function that will focus to application in the browser.

<object id="silverlightControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
  <param name="source" value="ClientBin/DragSnapDemo.xap"/>
  <param name="onError" value="onSilverlightError" />
  <param name="onLoad" value="silverlightControlHost_Load" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="3.0.40624.0" />
  <param name="autoUpgrade" value="true" />
  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0" style="text-decoration:none">
    <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
  </a>
</object>

3- Finally write the JavaScript function that is called when the Silverlight application has be loaded

function silverlightControlHost_Load(sender, args) 
{  
  var control = document.getElementById("silverlightControl");  
  control.focus();
}

Update: Found the following links that might be helpful

http://kb2.adobe.com/cps/155/tn_15586.html

http://www.actionscript.org/forums/archive/index.php3/t-120307.html

Chris Taylor
Thanks for your reply, I probably didn't give enough detail. The Flash object is not hosted on a web page. The url to the SWF is set directly on the WebBrowser control. That said I could use InvokeScript to write some javascript out. Secondly, setting focus to the Flash object doesn't seem to be enough. I need to get focus to an element within Flash and I can't get that to happen. The Flash SWF file is third party and outside our control.
Phill
@Phill, I am sorry I can't provide anymore information, as I said I have no knowledge of flash, I just hoped that the SL info might help you in the right direction.
Chris Taylor