PDA

View Full Version : Scaling a image in Flash...



7of9
April 24th, 2003, 11:33 AM
Does anyone out there have an example code that can
can scale a group of images with different sizes into one fixed size?

In other words, I have an array of images coming into my movie. that have different sizes. I place each image upon a Mc that resides inside another movie clip and resize accordling. The problem is, all of the images have to be the same size. I want to be able to import any size image and scale and resize it to a specific size.

andr.in
April 24th, 2003, 11:51 AM
you load 'em into your movie
_root.yourmc.loadMovie("yourphoto.jpg", #);
_root.yourmc._width = 100;
_root.yourmc._height = 50;


You load them into a movieclip and the resize the movieclip you loaded them into!

7of9
April 24th, 2003, 04:12 PM
I'm already using the _height and _width properties on my Mc.
I believe I have to use the _scalex and _scaley properies so I can import any size images. Don't know how though.

andr.in
April 25th, 2003, 07:48 AM
scalex and scaley work on percentages!
Be sure to change the size AFTER you load a new pic!

7of9
April 25th, 2003, 12:33 PM
Syko this is what I have so far...and it works but not the way I want it too. Maybe I'm not getting it.

One of the members wrote a function that sizes an image onto a movieclip and it works great. But only if the images are the same size. I want to be able to import any size image and scale if necessary and resize the image into my movieclip.

_global.resizeImage= function()
{
//maximum image dimensions
//Note: The images have to be the same size
//so they can be scaled the same.
wMax = 292; //42
hMax = 359; //109

if(img_mc._width > wMax || img_mc._height > hMax)
{
//which dimension is the most oversized
wDiff = img_mc._width - wMax;
hDiff = img_mc._height - hMax;
//calculate ratio
if(wDiff > hDiff)
{
ratio = (wMax/img_mc._width) * 100;
}
else
{
ratio = (hMax/img_mc._height) * 100;
}
}
else
{
//if image doesn't need to be resized set ratio to 100
ratio = 100;
}
img_mc._xscale = img_mc._yscale = ratio;
};