Questions about Load and Unload external swf files


I have a small project to load and unload two external swf files. Here’s the details of my project:

  1. There are two external swf files (glow.swf and down.swf)
  2. Button movie1_btn is used to load glow.swf
  3. Button movie2_btn is used to load down.swf
  4. Button remove_btn is used to remove either glow.swf or down.swf

The codes are as below and seems to work.

// Create a new Loader to load the swf files
var myLoader:Loader=new Loader();

// Set the location of the new Loader

// function to load the “glow.swf”

function loadMovie1(evt:MouseEvent):void {
// Is unload is required??

var myrequest:URLRequest=new URLRequest("glow.swf");


movie1_btn.addEventListener(MouseEvent.CLICK, loadMovie1);

// function to load the “down.swf”

function loadMovie2(evt:MouseEvent):void {
//Is unload is required??

var myrequest:URLRequest=new URLRequest("down.swf");

trace("Number of children in myLoader: " + myLoader.numChildren);


movie2_btn.addEventListener(MouseEvent.CLICK, loadMovie2);

// Function to remove the Loader

function removeMovie(evt:MouseEvent):void{

remove_btn.addEventListener(MouseEvent.CLICK, removeMovie);

I am very new to AS 3. My concept is still very poor. I have some questions:

  1. Why the loadMovie1 function and loadMovie2 function still working after I click the remove_btn to remove the myLoader? It seems that myLoader is not removed when removeMovie function is executed. It is still on the MainTimeline. Is it possible to really remove it?

  2. Why myLoader.numChildren is always zero? Isn’t the external movie loaded into the myLoader?

  3. Any possible problem with the above codes?

Thanks and best regards


It is enough to add loader instance once,
Calling unload before load is pointless since loader unloads clips automatically when new request is passed,
I’d recommend adding clips to root instead of stage.
Question 1: How you remove loader? Do you want to remove it completely?