Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2012, 07:56 PM   PM User | #1
bertilvg
New to the CF scene

 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
bertilvg is an unknown quantity at this point
Smile Load and unload in Flash as3 problems?

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;
}
bertilvg is offline   Reply With Quote
Reply

Bookmarks

Tags
code snippets, load and unload, loader, preloader

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:05 PM.


Advertisement
Log in to turn off these ads.