Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » Loading and Unloading an SWF file


Loading and Unloading an SWF file

Reply
  #1 (permalink)  
Old 12-02-10, 11:02 AM
mgdarland mgdarland is offline
New Member
 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Loading and Unloading an SWF file

Loading and Unloading an SWF file

I'm currently working on a educational project for e-learning. This project has multiple buttons for opening several specific SWF files. What I want to accomplish is to be able to use my container file with 3 primary buttons for the named SWF files and have them load in a specific location in the container SWF. Then I have a separate button that just needs to close the loaded SWF file. FYI, the 3 primary buttons will be covered by the loaded swf file. I'm including my AS3 code for review. I can load a SWF and close it once. After that, it doesn't work. I would appreciate any assistance.

Code:

stop();
sub1.about_btn.addEventListener(MouseEvent.CLICK, aboutLoad);
sub1.pdf_btn.addEventListener(MouseEvent.CLICK, pdfLoad);
sub1.myvideo_btn.addEventListener(MouseEvent.CLICK , videoLoad);
sub1.quiz_btn.addEventListener(MouseEvent.CLICK, quizLoad);

function aboutLoad(e:MouseEvent):void {
loadClip("about.swf");
}
function pdfLoad(e:MouseEvent):void {
loadClip("pdf.swf");
}

function videoLoad(e:MouseEvent):void {
loadClip("myvideo.swf");
}

function quizLoad(e:MouseEvent):void {
loadClip("quiz.swf");
}

var theLoader = new Loader();

theLoader.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, progHandler);
theLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, loadedHandler);

addChild(theLoader);
theLoader.x=102;
theLoader.y=85;
back1_btn.addEventListener(MouseEvent.CLICK, backClick);

function backClick(event:MouseEvent):void {
removeChild(theLoader);

}

function loadClip(t:String):void {
SoundMixer.stopAll();
var myUrl:URLRequest=new URLRequest(t);
theLoader.load(myUrl);
}

preText.visible=false;

function progHandler(erogressEvent):void {
preText.visible=true;
var myPercent = Math.floor((e.bytesLoaded/e.bytesTotal)*100);
preText.text="loading: "+myPercent+"%";
}

function loadedHandler(e:Event):void {
preText.visible=false;
}
Best,

Monte Darland
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Loading and Unloading External SWFs Tonix Flash & ActionScript 0 04-15-08 05:07 AM
Loading and unloading forms with .NET steesh Windows .NET Programming 4 06-05-06 10:46 AM


All times are GMT -5. The time now is 06:58 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.