PDA

View Full Version : loading external swf into movie clip on button press



punstc
April 18th, 2008, 12:32 PM
Im just making the switch to AS3 and i'm having some major problems loading in external swfs. In AS2 it was easy but from what i've found i'm just not understanding how it works in AS3. I have a movie clip that has my navigation in it that would call the external swfs for each section of the site, it also contains the backgound design for the site. I have my main movie set up for full browser for positioning. and i want to be able to position where my external swfs are loaded as well.

Any help would be much appreciated, i've been looking and trying to figure this out for a few days now.

thanks
Jake

.ral:cr
April 18th, 2008, 01:14 PM
where did you searched? there's a help in flash.
you need Loader, and URLRequest

loader = new Loader();
this.addChild (loader);
loader.load (new URLRequest(path));

punstc
April 18th, 2008, 01:46 PM
i've searched this forum and a few others i just dont understand how to implement the code or how to make it load on top of my main movie so it can be positioned. Everything I've found that is somewhat useful loads the movie and replaces the main one.

.ral:cr
April 18th, 2008, 05:14 PM
this.addChild (loader); will automaticaly add it to a top level, till you add a new child.

punstc
April 19th, 2008, 12:35 PM
okay i understand now thanks, everything else i read made it really confusing

gggmork
April 20th, 2008, 03:37 AM
Can I completely avoid using the confusing 'this' key word? For example I found these do the same thing (identical except 'this' is replaced with 'stage'). Also, if my jpg is in c:\ does that mean my .AS file HAS to also be in c:\ ?



var loader = new Loader();
this.addChild (loader);
loader.load (new URLRequest("C:\dummy.jpg"));

this.addChild(loader)




var loader = new Loader();
stage.addChild (loader);
loader.load (new URLRequest("C:\dummy.jpg"));

stage.addChild(loader)

bardic
May 6th, 2008, 10:39 AM
You can avoid using the this keyword. If you actually just do addChild(loader) it will add the loader to the top level of the object (Some please correct me if I'm wrong cuz if so I'd botched a lot of things xD). I don't recommend using stage, since it could cause problems later.

And no, you AS file does not have to be in C:\ but it's good practice to contain all a projects assests within the same root folder. So you would have

project/
main.as
img/
dummy.jpg

Then calling dummy.jpg would be img/dummy.jpg

Alex Lexcuk
May 6th, 2008, 03:45 PM
http://kind-armadillo.pochta.ru/fla/OSC_AC3.rar
http://kind-armadillo.pochta.ru/fla/osc.swf
External
http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.swf
http://kind-armadillo.pochta.ru/FlaAC3/RotateSWF.rar

http://kind-armadillo.pochta.ru/FlaAC3/curve.rar
http://kind-armadillo.pochta.ru/FlaAC3/curve.swf
External
http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.swf
http://kind-armadillo.pochta.ru/FlaAC3/loadSWF.rar