#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    165
    Rep Power
    11

    Set javascript var when playing or stopped/paused


    Hello,

    I'm using SWFObject 2.2 and neeed to set a javascript variable when the swf is playing or stopped/paused, but can't find how to do that.

    I looked into using callbackFn and ExternalInterface.addCallback, as well as the SWFObject docs.

    I'm trying to avoid having to create a function with a timeout or interval that checks the swf's isPlaying status. Is there a feature/function in Flash like whilePlaying or onTime, onStop, etc. that I can leverage? I couldn't find anything in the SWFObject docs, bit I could have just missed it.

    Unfortunately, I don't have access to the flash source, otherwise the options may be different.

    Thank you. This is the final thing I need to finish a new feature.

    Sincerely,
    Mike
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Hi, whilst there are some more JS functions there is nothing that will help you besides as you said, polling the isPlaying property.

    Since you don't have access to the source, maybe you can cheat and make a wrapper around your original swf. So you could have another swf file that loads in your original. The wrapper could inspect the child (original) clip and see what its current play state is and then call your JS function via ExternalInterface. You will simply be moving the polling from JS<->SWF to be SWF<->SWF but it will probably give you a more accurate play/stop state change.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    165
    Rep Power
    11
    thanks, Tann San. That's what I was afraid of. As it turns out, the Flash objects I need to monitor are apparently single frame, so isPlaying is always returning false.

    Thanks again.
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Well using the wrapper method you might be able to read variables from the original file. I'd say the simplest thing to try out is create a new FLA, create a Loader instance that loads in your original swf file. Then do a debug run on that and see what variables/events you can read from it.
    Quis custodiet ipsos custodes?

IMN logo majestic logo threadwatch logo seochat tools logo