views:

448

answers:

1

I am opening a popup window containing a flash movie using JavaScript. The popup contains a media player that uses SoundManager2. Users add files to the media player from the parent window. However, when reloading the parent window, the reference to the child window (media player) is lost. So, to bring focus to the media player, we currently have to call window.open, which reloads the url, thus interrupting the playing media.

Does anyone know of a way to focus the media player window without reloading its contents? I'm pretty sure Javascript is out. Is there a way to do this with ActionScript?

A: 

You could call a javascript function from Flash that gives that window focus, however, I'm not sure if there is a decent way of doing this that wouldn't potentially annoy a user, unless you can do it only when new media is added to the player.

In any case, ExternalInterface or getURL/navigateToURL will allow you to call a javascript function from Flash.

Alex Jillard
Thanks for the suggestion, Alex. We've implemented a message bus that allows us to send messages between windows via Flash. Using this, we've tried calling window.focus() on the media player. However, it appears that window.focus() only works from the active window. So, calling window.focus() on a background window seems to have no effect. Triggering an alert in the popup, however, fires the alert and brings focus to the popup. So, perhaps some other event, other than window.focus() will activate the popup more unobtrusively?