PDA

View Full Version : Resize loaded image to the size of the constantly resized container


wvxvw
11-12-2006, 07:34 PM
Hi all!
Here's my problem:
I have a function that redraws the container clip every frame. While the function is running I need to download an image inside the container and to resize the image to the size of the container. The particular problem is that if the picture is bigger than the container, when it'll be downloaded the size of the container will be the same that of the picture.
Here's a simplified code:
var MCL:MovieClipLoader = new MovieClipLoader();
var MCLL:Object = {};
MCLL.onLoadComplete = function(mc:MovieClip){
/*
When this is called, the mc's width and height are 0
*/
}
MCL.addListener(MCLL);
var container:MovieClip = _root.createEmptyMovieClip("container", 0);
container.h=5;
container.w=5;
_root.onEnterFrame = function(){
container.clear();
container.beginFill(0, 100);
container.moveTo(0, 0);
container.lineTo(container.w, 0);
container.lineTo(container.w, container.h);
container.lineTo(0, container.h);
container.lineTo(0, 0);
container.endFill();
container.w+=5;
container.h+=5;
}
MCL.loadClip(container, "image.jpg");
Thank you for any help.

wvxvw
11-13-2006, 04:55 AM
I've advanced a little bit, so that now it works, but in a weird way. So, if there's any other solution, I'll apprecate hearing it =)
I've managed to 'unsubscribe' the target clip from being resized in onLoadComplete, and I run different onEnterFrame from onLoadInit that resizes the loaded image to the proper size and subscribes it back to the main onEnterFrame.
But it stops the target clip for a second, so that the movement doesn't look smooth...