Results 1 to 5 of 5

Thread: How to execute code using ExternalInterface on page load?

  1. #1

    How to execute code using ExternalInterface on page load?

    I have been trying everything I can find to have code start on the window.onload event that uses callbacks exposed via the ExternalInterface. I've had many of the attempts working in IE, but Firefox is causing me grief.

    I tried simply calling the code via an "onload=" statement in the body tag for starters, but that didn't work because (I'm assuming) the Flash piece wasn't loaded when onload was called. So I tried putting a line in the Flash that calls a javascript function once it's loaded up. I tried this both by putting the ExternalInterface.call statement in a "this.onLoad=function(){" block as well as just putting the call at the end of the statements on frame 1 of my presentation (with a stop() on the frame) - either way it isn't happening in Firefox.

    I also tried using a setInterval in Javascript to test to see if one of the methods exposed via the ExternalInterface is an object (or not undefined). Once again, it's working in IE, but not in Firefox. Here's the code I'm using for that attempt:

    ==

    var intCheckIfLoadedInterval=0;

    function checkIfLoaded(){
    //alert(thisMovie("Media_Center").setDefaultClip);
    if(thisMovie("Media_Center").setDefaultClip!=undef ined){
    clearInterval(intCheckIfLoadedInterval);
    mediaCenterStartupFunction();
    }
    }

    function initMediaCenter(){
    document.getElementById('mediaCenter').style.top=" -700px";
    document.getElementById('mediaCenter').style.visib ility="visible";
    intCheckIfLoadedInterval=setInterval("checkIfLoade d()",500);
    }

    window.onload=initMediaCenter();

    ==

    Please let me know if you have any suggestions. The only other thing I can think of at the moment is using the swfObject for writing the flash tags to the page, but I'm already writing them from an external file (and removing the IE "Click to activate this control" issue in the process). All these methods work fine after the initial load (although I also had issues with Firefox when I simply try to call the onload instructions after a setTimeout command as well).

    Thanks for your help.

  2. #2

    ExternalInterface.call() in Firefox

    I've been having a similar problem with ExternalInterface.call() in Firefox. It will only work when my flash movie is actually visible on screen.

    I was having problems with larger documents when my flash was near the bottom. Basically my users needed to scroll down to the flash object before it would begin receiving calls from ExternalInterface.call().

    This recently began happening, so it must have been included in a Firefox update. Don't know if this is related to your script.. Thought I'd suggest it anyway.


    Quote Originally Posted by especht View Post
    I have been trying everything I can find to have code start on the window.onload event that uses callbacks exposed via the ExternalInterface. I've had many of the attempts working in IE, but Firefox is causing me grief.

    I tried simply calling the code via an "onload=" statement in the body tag for starters, but that didn't work because (I'm assuming) the Flash piece wasn't loaded when onload was called. So I tried putting a line in the Flash that calls a javascript function once it's loaded up. I tried this both by putting the ExternalInterface.call statement in a "this.onLoad=function(){" block as well as just putting the call at the end of the statements on frame 1 of my presentation (with a stop() on the frame) - either way it isn't happening in Firefox.

    I also tried using a setInterval in Javascript to test to see if one of the methods exposed via the ExternalInterface is an object (or not undefined). Once again, it's working in IE, but not in Firefox. Here's the code I'm using for that attempt:

    ==

    var intCheckIfLoadedInterval=0;

    function checkIfLoaded(){
    //alert(thisMovie("Media_Center").setDefaultClip);
    if(thisMovie("Media_Center").setDefaultClip!=undef ined){
    clearInterval(intCheckIfLoadedInterval);
    mediaCenterStartupFunction();
    }
    }

    function initMediaCenter(){
    document.getElementById('mediaCenter').style.top=" -700px";
    document.getElementById('mediaCenter').style.visib ility="visible";
    intCheckIfLoadedInterval=setInterval("checkIfLoade d()",500);
    }

    window.onload=initMediaCenter();

    ==

    Please let me know if you have any suggestions. The only other thing I can think of at the moment is using the swfObject for writing the flash tags to the page, but I'm already writing them from an external file (and removing the IE "Click to activate this control" issue in the process). All these methods work fine after the initial load (although I also had issues with Firefox when I simply try to call the onload instructions after a setTimeout command as well).

    Thanks for your help.

  3. #3
    AndreGD25
    n/a
    posts
    Guest

    External Interface

    So I'm having the same issue. I believe that because the Flash SWF has to expose the function call, that any type of onLoad or even using SWFObject's embedSWF call that allows for a call back function, won't work because the Flash SWF has not yet exposed that call. I'm a JS novice so I'm not sure of the best solution.

  4. #4
    Jurysko
    n/a
    posts
    Guest

    Unbelievable! Thanks!

    I've been solving this for hours! Firefox made me pretty angry. Thank you man, I animated div that displays flash and after adding timer until flash is fully visible it works like a charm.

  5. #5
    Jurysko
    n/a
    posts
    Guest

    Hmm

    Quote Originally Posted by AndreGD25 View Post
    So I'm having the same issue. I believe that because the Flash SWF has to expose the function call, that any type of onLoad or even using SWFObject's embedSWF call that allows for a call back function, won't work because the Flash SWF has not yet exposed that call. I'm a JS novice so I'm not sure of the best solution.
    I would try changing the swf. Try to include "ExternalInterface. ..." in base class and make it available from start. In your flash function handle the request - if flash isn't fully loaded response with something to js (like "unprepared") and js can show something for user. Once loaded, calling this callback flash function will response with proper reaction.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012