Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Loading mulitple external .swf files

This is a discussion on Loading mulitple external .swf files within the Actionscript 3.0 newbies forums, part of the Flash CS3 eng category; I built a loader with three buttons, each of which loads a different external swf. The code works, and all ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Flash CS3 eng > Actionscript 3.0 newbies

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 16-08-08, 19:07
Junior Member
 
Join Date: May 2008
Posts: 1
Rep Power: 0
mrentschler is on a distinguished road
Loading mulitple external .swf files

I built a loader with three buttons, each of which loads a different external swf. The code works, and all three buttons load the correct swf, but when I click the second button before the first swf is finished playing, the two movies overlap. If I click all three buttons in succession, all three swfs play, one over the other.

How do I code the buttons so they first stop the swf that is already playing, and then play the swf they are meant to load? Here is my code:

var imageRequest:URLRequest = new URLRequest("scene1.swf");

var imageLoader:Loader = new Loader();

welcomeBtn.addEventListener(MouseEvent.CLICK, loader);

function loader(event:MouseEvent){
imageLoader.load(imageRequest);
marker.addChild(imageLoader);
}

var imageRequest2:URLRequest = new URLRequest("scene2.swf");

var imageLoader2:Loader = new Loader();

designBtn.addEventListener(MouseEvent.CLICK, loader2);

function loader2(event:MouseEvent){
imageLoader2.load(imageRequest2);
marker.addChild(imageLoader2);
}

var imageRequest3:URLRequest = new URLRequest("scene3.swf");

var imageLoader3:Loader = new Loader();

sponsorBtn.addEventListener(MouseEvent.CLICK, loader3);

function loader3(event:MouseEvent){
imageLoader3.load(imageRequest3);
marker.addChild(imageLoader3);
}

Thanks, Flep! Your tutorials are the best!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 09-10-08, 22:24
Junior Member
 
Join Date: Apr 2008
Posts: 2
Rep Power: 0
epocs is on a distinguished road
Re: Loading mulitple external .swf files

hey mrentschler, im a newb but i think what you are looking for is removeChildAt(i);
with "i" being an array index. since you are loading 1 object into the marker mc, it is a child of marker mc in the first index (0)

so in the mouse event functions you can just remove any children before loading the next swf, ie:

function loader(event:MouseEvent){
marker.removeChildAt(0);
imageLoader.load(imageRequest);
marker.addChild(imageLoader);
}

theres probably a better way to do it..but thats my 2 cents
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

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

Similar Threads

Thread Thread Starter Forum Replies Last Post
Actionscript 3 unload External swf files with AS3 andrei advanced Actionscript 3.0 2 08-11-08 16:08
Actionscript 3 loading external swf, help please scorptique advanced Actionscript 3.0 1 15-10-08 05:25
Problem with loading external swf madmad Actionscript 3.0 newbies 2 28-05-08 21:36
load External swf files with AS3 tuanDuy advanced Actionscript 3.0 1 28-05-08 21:28
Loading external XML files with Flash CS3 Flep Tutorials 14 19-11-07 15:23


All times are GMT. The time now is 22:22.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406