Skip to content Skip to sidebar Skip to footer

When Can Javascript Start Calling Actionscript?

Question Is there a non-polling way for Javascript to command Flash right when its external interface is ready? Background In Actionscript, I've registered a function for Javascrip

Solution 1:

In Javascript:

functionflashIsReady()
{
    $('flashPlayer').doStuff();
}

In Actionscript:

if (ExternalInterface.available) {
    ExternalInterface.addCallback('doStuff', this.doStuff);
    ExternalInterface.call("flashIsReady");
}

Solution 2:

I did a polling solution. In actionscript I have a function like this:

private function extIsInterfaceReady():Boolean {return ExternalInterface.available;
}

And in javascript, after the 'onFlashReady' event I also have coded into intialization, I start an interval like this:

this.poll_flash = setInterval( function() {
    if ( typeof this.flash_obj === 'undefined' ) {
      returnfalse;
    }

    if ( typeof this.flash_obj.isInterfaceReady === 'undefined' ) {
      returnfalse;
    }

    if ( this.flash_obj.isInterfaceReady() ) {
      clearInterval(this.poll_flash);
      returnthis.continueOn();
    }
  }, 100);

Post a Comment for "When Can Javascript Start Calling Actionscript?"