开发者

Removing a SWF via unloadAndStop();

开发者 https://www.devze.com 2023-01-14 04:58 出处:网络
Alright so I\'m a flash newb.Our flash guy left, ugh. I\'ve been struggling for days on this and I need to get this done so any help would be greatly appreciated.

Alright so I'm a flash newb. Our flash guy left, ugh.

I've been struggling for days on this and I need to get this done so any help would be greatly appreciated.

Here's the scenario.

I'm importing a background swf with rotating images for each page. It works great. But as I'm sure you could of guess by now, it won't unload when another page is clicked.

I can get the swf to stop playing but it just sits there in the background.

Here's the code

var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("backgroundrecruitment.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventL开发者_Go百科istener(ProgressEvent.PROGRESS, onProgressHandler);

function addImage6()
{
mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event)
{
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}


function removeImage6()
{
mLoader.unload();
mLoader.unloadAndStop();
trace("working");
}

When I click another button I call the removeImage6 function.

Can anyone point me in the right direction?


that would be one way to do it

function onCompleteHandler(loadEvent:Event)
{
   addChild(mLoader);
}

function removeImage6()
{
   removeChild(mLoader);
}

but you could also do this:

function onCompleteHandler(loadEvent:Event)
{
   var content:MovieClip = loadEvent.currentTarget.content;
   content.name = "backgroundSWF";
   addChild(content);
}

function removeImage6()
{
   removeChild(getChildByName("backgroundSWF"));
}

When you add the Loader content to the display list, the content is not a child of the Loader anymore, so you can't unload it...

0

精彩评论

暂无评论...
验证码 换一张
取 消