AS3 - Resizing a MovieClip according to the size of a dynamically loaded image
Hello all,
I wonder if any of you can point me in the right direction. In my stage I have a movieclip where I want to load several images with different sizes. This mc called "container" adds the loader to the stage so I'm asking for the loader width and height once has finished loading and then passing these to the width and height of the mc container so it resizes accordingly. But...it doesn't work.
Here is my code:
var pic:Loader;
var totalImages:int = 10;
for (var i:uint = 0; i<totalImages; i++){
pic = new Loader()
container.addChild(pic)
pic.load(new URLRequest(myImages))
pic.addEventListener(Event.COMPLETE, resizeContainer)
}
function resizeContainer(e:Event):void{
container.width = pic.width;
container.height = pic.height
}
The above code works but doesn't resize properly and it actually resizes the container and the photo at the same time...What am I doing wrong?
Thanks a lot for your help in advance.
Txusm