Please help, Remove child for external swfs?

Hi All-

Thanks for bearing with me on this bit of code…I know I’m such a noob. :expressionless:

Dilemma of the moment:

My main site has a left hand navigation menu made of five buttons (about, portfolio, services, contact, news). When you click on portfolio, nine little buttons pop up at the bottom, each linking to an external swf on mouse click.

My only problem is, when you go to another section outside of “portfolio”, say, “contact”, and then go back to “portfolio”, you can still see the last portfolio item you chose to view.

This leads me to believe I need to somehow use remove child to get rid of the loader whenever someone clicks on a button in the main navigation (about, portfolio, services, contact, & news).

After many [unsuccessful] attempts at coming up with a solution, I think I’ll post the code I am using now without the various “remove child” code mutilations I came up with, in the hopes that someone might be able to help…



stop();

var IMGloader:Loader

BTN_GAL_1.addEventListener(MouseEvent.CLICK,loadImage);
BTN_GAL_2.addEventListener(MouseEvent.CLICK,loadImage)
BTN_GAL_3.addEventListener(MouseEvent.CLICK,loadImage)
BTN_GAL_4.addEventListener(MouseEvent.CLICK,loadImage)
BTN_GAL_5.addEventListener(MouseEvent.CLICK,loadImage)
BTN_GAL_6.addEventListener(MouseEvent.CLICK,loadImage)
BTN_GAL_7.addEventListener(MouseEvent.CLICK,loadImage)
//...add the other buttons here

function loadImage(e:MouseEvent){
	var IMGPath:URLRequest;
	
	switch(e.target){
		case BTN_GAL_1: IMGPath = new URLRequest("GAL_SWFS/VimTeaser.swf");
				   break;
		case BTN_GAL_2: IMGPath = new URLRequest("GAL_SWFS/VimInClosed.swf");
				   break;
		case BTN_GAL_3: IMGPath = new URLRequest("GAL_SWFS/VimInOpen.swf");
				   break;
		case BTN_GAL_4: IMGPath = new URLRequest("GAL_SWFS/UMPR.swf");
				   break;
		case BTN_GAL_5: IMGPath = new URLRequest("GAL_SWFS/MTFlags.swf");
				   break;
		case BTN_GAL_6: IMGPath = new URLRequest("GAL_SWFS/SOS.swf");
				   break;
		case BTN_GAL_7: IMGPath = new URLRequest("GAL_SWFS/MTRecNews.swf");
				   break;
		  default: trace("Error: loadImage called by unknown button");
		  		   break;
	}
	
   IMGloader = new Loader();
   IMGloader.load(IMGPath)

   IMGloader.x = 166
   IMGloader.y = 46

   addChild(IMGloader)
}