An alternative is to use the Externalinterface for communication between Javascript and Actionscript. With it it is possible to pass Javascript commands to Actionscript and vice versa.
First you can listen to your SWF load using the code below in the first application frame:
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 {
trace("Carregando..."+Number((e.bytesLoaded/e.bytesTotal)*100));
}
function carregouSWF(e:Event):void {
trace("Carregou o SWF!");
ExternalInterface.call("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:
Javascript:
function escutarSWF(param) {
console.log(param);
}
Actionscript:
ExternalInterface.call("escutarSWF", "Olá! Eu sou o ActionScript!");
Because the two languages are inherited from Ecmascript, communication between them is effective and functional, I believe you can use them together.
I don’t know if there is any other alternative, but for pure Javascript, I believe this is the most reliable.
The most practical would be to use swfObject. Another alternative would perhaps be from within the SWF to use the external interface and call a Javascript to warn the page your swf loaded. http://stackoverflow.com/questions/883680/externalinterface-calling-javascript-from-swf
– Tony
Thanks Tony, I had thought about this tmb, but I thought there was another way, I researched here and probably there is no other way, thanks for the XD reply
– Douglas dos Santos
Why not use the recommended mode, which is swfObject?
– Tony
It is a limitation of the project, because it deals with a banner 'special' in which javascript interacts with swf, and not allowed the insertion of swfObject, tmb I think it’s boring this but do what right.... higher orders
– Douglas dos Santos
You can use or are already using jQuery?
– brasofilo
so brsofilo the project has the limitation of being able to use only pure javascript(a bag), but I’ll take the advice from Tony that is to warn javascript when swf is loaded using the Externalinterface, thanks for the answer
– Douglas dos Santos