javascript – How to detect that the swf has been loaded


I would like to know if it is possible to detect when the swf is loaded:

Here's the code:

<object id="teste"  name="teste" type="application/x-shockwave-flash" data="120x600.swf" width="550" height="400" onload="alert('carregado')">
   <param name="movie" value="120x600.swf"/>
   <param name="quality" value="high"/>
   <param name="allowscriptaccess" value="always"/>
   <a href="">
   <img src="" alt="Get Adobe Flash player"/>

* I tried using the onload parameter but it doesn't seem to work on the object tag

* Ah, I can't use swfObject , project limitations.


An alternative is to use the ExternalInterface for communication between JavaScript and ActionScript. With it you can pass commands from JavaScript to ActionScript and vice versa.

First you can hear your SWF load using the code below in the first frame of the application:

this.loaderInfo.addEventListener(Event.OPEN, iniciouCarregamento);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, carregando);
this.loaderInfo.addEventListener(Event.COMPLETE, carregouSWF);

function iniciouCarregamento(e:Event):void {
    trace("Iniciou carregamento");

function carregando(e:ProgressEvent):void {

function carregouSWF(e:Event):void {
    trace("Carregou o SWF!");"console.log", "Carregou o SWF!"); //Chama uma função do javascript, no caso, o "console.log", e passa como parâmetro a string "Carregou o SWF!"

In javascript you can use a custom function and call it by the same method like this:


function escutarSWF(param) {

ActionScript:"escutarSWF", "Olá! Eu sou o ActionScript!");

Because both languages ​​are ECMAScript inheritance, the communication between them is efficient and functional, I believe you can use them together.

I don't know if there is any other alternative, but for pure JavaScript I think this one is the most reliable.

Scroll to Top