user1942505
user1942505

Reputation: 520

How to check if an SWF file loaded (ActionScript)

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

Answers (2)

Dub4ek
Dub4ek

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

Lars Blåsjö
Lars Blåsjö

Reputation: 6127

Try root.loaderInfo.addEventListener(Event.COMPLETE, onComplete) instead.

Upvotes: 1

Related Questions