Hi guys, I am using a code snippet in flash cs6 as3, that takes a button and when you click it, it will load a swf, and when you click the button again, it will unload.... My question is, can some of you rewrite the code so we actually remove the button, and flash does the work automaticully when it reach a speciel frame?.. What I want is the code to say "when I reach this frame, load this swf, and when I reach another frame, unload it... " I want to use it to a game I am making... Thank you!!

Here is the snippet:


/* Click to Load/Unload SWF or Image from a URL.
Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.

Instructions:
1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
*/

button_2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);

import fl.display.ProLoader;
var fl_ProLoader_2:ProLoader;

//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad_2:Boolean = true;

function fl_ClickToLoadUnloadSWF_2(event:MouseEvent):void
{
if(fl_ToLoad_2)
{
fl_ProLoader_2 = new ProLoader();
fl_ProLoader_2.load(new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg"));
addChild(fl_ProLoader_2);
}
else
{
fl_ProLoader_2.unload();
removeChild(fl_ProLoader_2);
fl_ProLoader_2 = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad_2 = !fl_ToLoad_2;
}