PDA

View Full Version : addChild + loading external images



Grofit
October 1st, 2007, 09:28 AM
hey,

im trying to load external images, and everything i see tells me to myVar.addChild(loaderWithImage), but i dont really get what im meant to do with it then...

Ive tried setting _x,_y to 100 to set it on screen but aint seeing anything...

I tried making a new movieclip and adding the child that way, is there any chance someone could show me a barebones way to load images then display them on screen?

hakukaji
October 1st, 2007, 10:18 AM
try this out



var ldr:Loader = new Loader();
var url:String = "image path"; //wherever the image is
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
ldr.x = 100;
ldr.y = 100; //remember in as3 it's x&y instead of _x&_y
addChild(ldr);

Grofit
October 1st, 2007, 10:24 AM
thats pretty much what i have here although im doing

loader.load(new URLRequest(ImagePath));

how do you access that child once you add the child to something?

hakukaji
October 1st, 2007, 10:25 AM
in this case it would just be ldr, or parent.getChildAt(#)

Grofit
October 1st, 2007, 10:39 AM
brilliant, while we are doing fast responses quick question.

How do you reference a movieclip in an external class?

So if i have a movieclip in the scene called movRandom (thats the instance name), i tried just calling it like a variable but it didnt work...

hakukaji
October 1st, 2007, 11:52 AM
i assume it's an external swf? if so just load it up using the same method, and make changes to the loader instance.