Reputation: 520
How do I check if an SWF file loaded?
I want to execute a script when an SWF file has finished loading,
root.addEventListener(Event.COMPLETE, onComplete);
root.addEventListener(ProgressEvent.PROGRESS, onProgress);
function onProgress(e:ProgressEvent):void
{
trace("onProgress");
}
function onComplete(e:Event):void
{
trace("onComplete");
}
Upvotes: 0
Views: 1095
Reputation: 46
I resolved this problem by sending the dispatchEvent
from the loading SWF file to the loaded SWF file:
In the loading SWF file: when the load is complete, do dispatchEvent(new Event("Bla-bla"));
In the loaded SWF file: addEventListener("Bla-bla", someHandler);
First SWF file:
var load:Loader = new Loader(new URLReauest("name of loaded swf"));
load.addEventListener(Event.Complete, completeHandler);
function completeHandler(event:Event):void
{
var currentLoadedSWF:MovieClip = event.target.loader;
currentLoader.dispatchEvent(new Event("Bla-Bla"))
}
In the second SWF file, in the constructor, put in this code:
addEventListener("Bla-Bla", someHandler)
Or you can call any public methods in the loaded SWF file.
Upvotes: 0
Reputation: 6127
Try root.loaderInfo.addEventListener(Event.COMPLETE, onComplete)
instead.
Upvotes: 1