Buttons and external swfs
I would like to automatically load an external swf inside an existing empty mc (or a new one) and load/unload different external swf on several button click fuctions. I've read the other posts, but none that quite facilitates accomplishing this.
This is what I have, I know it's messy- but I've been trying so many different methods until its probably loaded with irrelevant functions!
var myLoader:Loader = new Loader(); addChild(myLoader); var url:URLRequest = new URLRequest("homepage.swf"); myLoader.load(url);
myLoader.x=477;
myLoader.y=0;
/* 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_1.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
var fl_Loader:Loader;
//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
if(fl_ToLoad)
{
fl_Loader = new Loader();
fl_Loader.load(new URLRequest("homepage.swf"));
fl_Loader.x=477;
fl_Loader.y=0;
removeChild(myLoader);
removeChild(fl_Loader_2);
removeChild(fl_Loader_3);
removeChild(fl_Loader_4
addChild(fl_Loader);
);
}
else
{
fl_Loader.unload();
removeChild(fl_Loader);
removeChild(myLoader);
removeChild(fl_Loader_2);
removeChild(fl_Loader_3);
removeChild(fl_Loader_4);
fl_Loader = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad = !fl_ToLoad;
}
/* 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.
*/
movieClip_2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);
var fl_Loader_2:Loader;
//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_Loader_2 = new Loader();
fl_Loader_2.load(new URLRequest("portfolio.swf"));
fl_Loader_2.x=477;
fl_Loader_2.y=0;
removeChild(myLoader);
removeChild(fl_Loader);
removeChild(fl_Loader_3);
removeChild(fl_Loader_4);
addChild(fl_Loader_2);
}
else
{
fl_Loader_2.unload();
removeChild(fl_Loader_2);
removeChild(fl_Loader);
removeChild(fl_Loader_3);
removeChild(fl_Loader_4);
fl_Loader_2 = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad_2 = !fl_ToLoad_2;
}
/* 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.
*/
movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_3);
var fl_Loader_3:Loader;
//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad_3:Boolean = true;
function fl_ClickToLoadUnloadSWF_3(event:MouseEvent):void
{
if(fl_ToLoad_3)
{
fl_Loader_3 = new Loader();
fl_Loader_3.load(new URLRequest("about.swf"));
fl_Loader_3.x=477;
fl_Loader_3.y=0;
removeChild(myLoader);
removeChild(fl_Loader_2);
removeChild(fl_Loader);
removeChild(fl_Loader_4);
addChild(fl_Loader_3);
}
else
{
fl_Loader_3.unload();
removeChild(fl_Loader_3);
removeChild(fl_Loader_2);
removeChild(fl_Loader);
removeChild(fl_Loader_4);
fl_Loader_3 = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad_3 = !fl_ToLoad_3;
}
/* 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.
*/
movieClip_4.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_4);
var fl_Loader_4:Loader;
//This variable keeps track of whether you want to load or unload the SWF
var fl_ToLoad_4:Boolean = true;
function fl_ClickToLoadUnloadSWF_4(event:MouseEvent):void
{
if(fl_ToLoad_4)
{
fl_Loader_4 = new Loader();
fl_Loader_4.load(new URLRequest("contact.swf"));
fl_Loader_4.x=477;
fl_Loader_4.y=0;
removeChild(myLoader);
removeChild(fl_Loader_2);
removeChild(fl_Loader_3);
removeChild(fl_Loader);
addChild(fl_Loader_4);
}
else
{
fl_Loader_4.unload();
removeChild(fl_Loader_4);
removeChild(fl_Loader_2);
removeChild(fl_Loader_3);
removeChild(fl_Loader);
fl_Loader_4 = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad_4 = !fl_ToLoad_4;
}