2

I'm trying to load external SWFs in a for loop, and I have this problem that is really eating me: In the event handler I need to know the filename of the SWF that was loaded, but I can't obtain this. The code below shows what I'm trying to do.

Does anybody have any idea?

function loadManySWFs(arrayOfFileNames:Array)
{
    for(var i=0; i<arrayOfFileNames; i++)
    {
        var mLoader:Loader = new Loader();
        var mRequest:URLRequest = new URLRequest(arrayOfFileNames[i]));
        mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
        mLoader.load(mRequest);
    }

}


function onLoadComplete(e:Event)
{
    // Here I need to know the filename of the SWF that was loaded. How can I do this?

}

Thanks for any help!

1 Answer 1

4

event.target would contain the relevant LoaderInfo object, you can retrieve the url from that.

function onLoadComplete(e:Event):void {
    trace(LoaderInfo(e.target).url);
}
Sign up to request clarification or add additional context in comments.

1 Comment

@maxmc event.target would be the LoaderInfo object with which the event listener was registered. Edited to fix it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.