Hi guys,
I’m new on As and I’m doing some lessons. I’m loading 2 external images and than positioning them one near the other.
Here is how I do this:
var img1:URLRequest = new URLRequest("img/img1.jpg");
var loaderImg1:Loader = new Loader();
function fileCaricato (event:Event):void
{
var immagine1_mc:MovieClip = new MovieClip();
addChild(immagine1_mc);
immagine1_mc.addChild(loaderImg1);
immagine1_mc.scaleX = .25;
immagine1_mc.scaleY = .25;
var img2:URLRequest = new URLRequest("img/img2.jpg");
var loaderImg2:Loader = new Loader();
function fileCaricato2 (event:Event):void
{
var immagine2_mc:MovieClip = new MovieClip();
addChild(immagine2_mc);
immagine2_mc.addChild(loaderImg2);
immagine2_mc.x = immagine1_mc.width +10;
}
loaderImg2.contentLoaderInfo.addEventListener(Event.COMPLETE, fileCaricato2);
loaderImg2.load(img2);
addChild(loaderImg2);
}
loaderImg1.contentLoaderInfo.addEventListener(Event.COMPLETE, fileCaricato);
loaderImg1.load(img1);
addChild(loaderImg1);
It works and it’s fine but i think it’s a little bit to tricky to make every time.
First of all can you say if it’s correct or there is some more smart way to do this?
Thanks,
Angel