Unloading an External SWF

Hi,

I’m building a site that has 7 sections. 1 section is a Photo Gallery for which I’m loading an external SWF file that is controlled by an XML file. Im doing this for allowing content editing any time.

All of the other content on the site is one-time, no backend required.

I’ve successfully loaded the external swf file into a loader in one of the frames. However, when I navigate away to the other 6 sections, I’m unable to unload the external SWF loader. How do I go about this?

Here’s my code that loads the external SWF in one frame:

import flash.events.MouseEvent;

//This creates a new instance of the loader object.
var my_Loader:Loader = new Loader();

//This creates a new instance of the URLRequest object that contains the
//path to the external SWF.
var my_url:URLRequest=new URLRequest("gallery.swf");

//These listeners detect when the file has finished loading, and if the
//correct file is loaded.
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

//The load method then loads the SWF file into the loader object.
my_Loader.load(my_url);

//This will offset the load SWF file, so be appear at (20, 20) on the stage.
my_Loader.x = 37.85;
my_Loader.y = 74.90;

//This function adds the external SWF to the stage.
function finishLoading(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
}

//This function displays a message if the file is not found.
function errorHandler(errorEvent:Event):void {
trace("file missing");
}

stop();

Here’s the code I’m using for the site navigation buttons. I tried adding my_Loader.unload(); for all of the button Event listener functions. Its still not working.

import flash.events.MouseEvent;

vinaybtn.addEventListener(MouseEvent.CLICK, vinay);

function vinay(event:MouseEvent):void
{
    my_Loader.unload();
    gotoAndStop(2);
}


priyabtn.addEventListener(MouseEvent.CLICK, priya);

function priya(event:MouseEvent):void
{
    gotoAndStop(3);
}


gallerybtn.addEventListener(MouseEvent.CLICK, gallery);

function gallery(event:MouseEvent):void
{
    gotoAndStop(4);
}


bestwishesbtn.addEventListener(MouseEvent.CLICK, bestwishes);

function bestwishes(event:MouseEvent):void
{
    my_Loader.unload();
    gotoAndStop(5);
}

invitationbtn.addEventListener(MouseEvent.CLICK, invitation);

function invitation(event:MouseEvent):void
{
    gotoAndStop(6);
}

rsvpbtn.addEventListener(MouseEvent.CLICK, rsvp);

function rsvp(event:MouseEvent):void
{
    gotoAndStop(7);
}

Any help would be much appreciated.

Thanks,
Sudarshan