Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resize images

Status
Not open for further replies.

Fion

Vendor
Sep 25, 2003
50
US
Hi all,
Does anyone know how I could go about resizing images as they are loaded into a movie with loadMovie()? This is for a photo gallery that I am making. When you click on the thumbnail of the picture, a frame fades in and a larger version of that picture is loaded onto that frame. Most of my pictures are quite a bit larger then the "large" frame, so I would like the ability to resize the images as they are loaded. I don't want to actaully change the size of the image, as I have another button that displays the fullsize picture in a blank html page, but resize them into the frame.
Thank you for your help. :)
 
Load the new image into a blank MC (let's say with the instance name "theImage").

Code:
loadMovie("imageName.jpg",theImage);
theImage._xscale = 50;
theImage._yscale = 50;

You will most likely want to look into using movieClipLoader.loadClip() instead so you can monitor the progress of the image load.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Sweet, thanks! Is there a way to detect the size of the picture that I am importing, so that I can know how much to scale it? (I am running on the assumption that pictures may be different sizes, so the same amount of scaling might not be appropreate for all of them.)
 
you can only detect this after its loaded and the movieclip.onLoad dont work properly in flash

this files fixes the problem


in frame 1 of the movie

#include "preload.as"

//with a empty clip instance name imageClip

imageClip.onLoad = function() {
//make sure image is always centered
imageClip._x = (stage.width-imageClip._width)/2;
imageClip._y = (stage.height-imageClip._height)/2;
};
 
Thank you, that worked perfectly. Thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top