tags:

views:

11

answers:

1

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.addEventListener(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?

A: 

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...

PatrickS
good man! thanks so much!