Paul
Paul

Reputation: 6176

how to get back the loader after Event.COMPLETE with my code? (as3, flash)

can you please tell me how you get the loader back after a Event.COMPLETE?

i tried the example from the doc, i tried different stuff, but i always have a "error to convert Loader in LoaderInfo, or in myImport..."

this does not work : TypeError: Error #1034:

function loader_my_import(){
    var loader = new Loader();
    var url:URLRequest = new URLRequest("myImport.swf");
    loader.load(url);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete_imgs);
}

function complete_imgs(e:Event){
      loader_IMGS = Loader(e.target.content);
}

loader_IMGS being already declared at the beginning of the class.

Thanks

Upvotes: 0

Views: 7820

Answers (1)

Patrick
Patrick

Reputation: 15717

It doesn't work because e.target is a LoaderInfo object not a loader (you add the event listener to the contentLoaderInfo ). From the LoaderInfo you can then get the originate loader

So it should be :

function complete_imgs(e:Event){
 var li:LoaderInfo = LoaderInfo(e.target)
 var loader:Loader = li.loader
}

Upvotes: 3

Related Questions