[COLOR=#000000][FONT=verdana]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!![/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]Here is the snippet:[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]/* Click to Load/Unload SWF or Image from a URL.[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]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.[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]Instructions:[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]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 ("").[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]*/[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]button_2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]import fl.display.ProLoader;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var fl_ProLoader_2:ProLoader;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]//This variable keeps track of whether you want to load or unload the SWF[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]var fl_ToLoad_2:Boolean = true;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]function fl_ClickToLoadUnloadSWF_2(event:MouseEvent):void[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]if(fl_ToLoad_2)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]fl_ProLoader_2 = new ProLoader();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]fl_ProLoader_2.load(new URLRequest(“http://www.helpexamples.com/flash/images/image1.jpg”));[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]addChild(fl_ProLoader_2);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]else[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]{[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]fl_ProLoader_2.unload();[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]removeChild(fl_ProLoader_2);[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]fl_ProLoader_2 = null;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]// Toggle whether you want to load or unload the SWF[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]fl_ToLoad_2 = !fl_ToLoad_2;[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]}[/FONT][/COLOR]