SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2003
    Location
    Canada
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onFocus() onBlur() Control

    I have an odd problem here.

    I am trying to control the playback head in flash by wether its parent page is focus or not. The file is meant to play continuisly but contains some external links throughout the presentation. So I want playback to cease when the new windows open and start again when the window containing the flash file comes back into focus.

    Using this:
    function PassFlashFocus(){
    window.document.MyFlashFile.SetVariable("state", "focus");
    }

    function PassFlashBlur(){
    window.document.MyFlashFile.SetVariable("state", "blur");
    }

    and this:
    <body onFocus="PassFlashFocus()" onBlur="PassFlashBlur()">

    Now this works fine if you click from one window to another. As focus changes the playback stops and starts. However....

    The Problem....

    When you click on the swf anywhere at all the JS tells flash the window blurred. If you click on the space around the flash file (still in the document) the JS tells flash the file is now focused again.

    Does anyone know what is up? I thought the body tag represented the window level in the DOM. Does anyone know a work around for this. It seems so simple yet I've wasted an enormous amount of time with no sucess.

    Any help is appreciated

    Thanks
    FJ

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Flashjunkie, Welcome to SitePoint Forums!

    I looked into this a little when another member asked this same question recently. I'm no expert on this topic, but I did not find a decent work-around.

    The effects you're describing are correct. When the swf object, or any form control, etc. receive the focus then the window loses the focus. In IE only (I think), you can use document.activeElement to determine the element currently focused. But even with IE's proprietary properties/methods I could not find a way to determine when the user has focused another window. Hopefully someone else knows of a way to do it - I didn't get to spend too much time on it.

    BTW, in IE the swf object as well as the form controls are implemented as "windowed" objects.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •