AS3:: Loading SWF issue

58 views Asked by At

I have some problem by loading an SWF.

This is my code

if (stage.contains(myLoader))
{
    myLoader.content['onRemove']();
    stage.removeChild(myLoader);
}

urlReq = new URLRequest("rent_.swf");
myLoader.load(urlReq);
stage.addChild(myLoader);

And everythings works fine. But when i try to add an Event.COMPLETE listener, then I get the error 1009

if (stage.contains(myLoader))
{
    myLoader.content['onRemove']();
    stage.removeChild(myLoader);
}

urlReq = new URLRequest("rent_.swf");
myLoader.load(urlReq);

function completeRent(e:Event):void{
    stage.addChild(myLoader);
}

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeRent);

I've allready checked the code in rent_.swf and everything is fine there.

The problem appears only when I add the Event.COMPLETE listener.

I wan't to put a preloader to load this SWF.

Can anyone Help?

///////////////////////////////////////////////////////////////

There is the corrected code:

if (stage.contains(myLoader))
{
    myLoader.content['onRemove']();
    stage.removeChild(myLoader);
}

urlReq = new URLRequest("rent_.swf");
myLoader.load(urlReq);
stage.addChild(myLoader);

function completeRent(e:Event):void
{
    //some tweens
}

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeRent);

In this form, everythnig worsk fine!

0

There are 0 answers