Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Change image size at runtime in flash

Newbie
 
Join Date: Feb 2008
Posts: 2
#1: Feb 27 '08
I am developing photo gallery in Macromedia Flash 8 and XML to retrive the Image. Image Size is all in different size. my question is How to Change image size at runtime in flash? so that image display one by one automatically with correct resized image please help thanks in advances

nomad's Avatar
Expert
 
Join Date: Mar 2007
Location: CA.
Posts: 570
#2: Feb 27 '08

re: How to Change image size at runtime in flash


Quote:

Originally Posted by kadarkarai

I am developing photo gallery in Macromedia Flash 8 and XML to retrive the Image. Image Size is all in different size. my question is How to Change image size at runtime in flash? so that image display one by one automatically with correct resized image please help thanks in advances


Just a word of advice:
Always bring your images into Flash at the actual size (pixel dimensions) you intend to use them at. Anytime you scale an image on the Flash Stage, it will be resampled and interpolated. Photoshop if you have it does a much better job than Flash when it comes to resampling. The only exception to this rule is when you are animating the scale of an image. Of course, in that scenario, it is always best to bring the image in from Photoshop at its largest size in the desired animation.

nomad
Rabboni's Avatar
Newbie
 
Join Date: Feb 2008
Posts: 3
#3: Feb 29 '08

re: How to Change image size at runtime in flash


to change the image size

first u convert that images into movieclip and then set the height and width of that movieclip
at runtime
Newbie
 
Join Date: Feb 2008
Posts: 2
#4: Mar 20 '08

re: How to Change image size at runtime in flash


Quote:

Originally Posted by Rabboni

to change the image size

first u convert that images into movieclip and then set the height and width of that movieclip
at runtime


Thanks Robboni
thats my question how to resize at runtime? i dont know the logic of that one
Newbie
 
Join Date: Jun 2008
Posts: 1
#5: Jun 25 '08

re: How to Change image size at runtime in flash


if(canvas._width/canvas._height>target_mc._width/target_mc._height)

i stole this code from "photoreel.fla" i can remember where in the Web it is





here is the full code for the image resize

if(canvas._width/canvas._height>target_mc._width/target_mc._height)
{
//set the image height to the canvas' height
target_mc._height=canvas._height;
//scale the width according to the height, to fit into the canvas dimensions
target_mc._xscale=target_mc._yscale;
//move the image to the center of the canvas
target_mc._x=(canvas._width-target_mc._width)/2;
}else{
//canvas is higher or equal to the proportions of the image
//set the width to the canvas' width
target_mc._width=canvas._width;
//fit the height into the canvas
target_mc._yscale=target_mc._xscale;
//move the image into the center vertically
target_mc._y=(canvas._height-target_mc._height)/2;
}
Newbie
 
Join Date: Oct 2008
Posts: 2
#6: Oct 26 '08

re: How to Change image size at runtime in flash


My problem is different. I have the fixed size movie clip and images are of different size. I want the image to be auto fix in that movie clip size. Support my movie clip is 200x200 and the image is 300x300, then I want this image to be completely visible but in 200x200 only. Currently the image is getting cut and cant see the complete image if its large. Please help
joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
#7: Oct 27 '08

re: How to Change image size at runtime in flash


Quote:

Originally Posted by geek4geek

My problem is different. I have the fixed size movie clip and images are of different size. I want the image to be auto fix in that movie clip size. Support my movie clip is 200x200 and the image is 300x300, then I want this image to be completely visible but in 200x200 only. Currently the image is getting cut and cant see the complete image if its large. Please help

The only way a flash file size(the whole thing) is if you change the size under the properties, so why not edit the image size while editing the flash file size at the same time, to see what it looks like before publishing. And I don't think you can resize just plain bitmaps(images). I think it needs to be converted to a MovieClip

joedeene
Newbie
 
Join Date: Oct 2008
Posts: 2
#8: Oct 27 '08

re: How to Change image size at runtime in flash


Quote:

Originally Posted by joedeene

The only way a flash file size(the whole thing) is if you change the size under the properties, so why not edit the image size while editing the flash file size at the same time, to see what it looks like before publishing. And I don't think you can resize just plain bitmaps(images). I think it needs to be converted to a MovieClip

joedeene

Thanks joedeene. But I have been googling the whole day and got frustrated with the fact that everybody is talking on forums about resizing the MovieClip and that is what I am able to do. But nobody is talking about -- "Making the image itself to fit in the moviw clip". I have tried all possible combinations (like resizing he loader.content, creating BitmapData and resizing it etc). I am able to resize the movie clip but not the image to fit completely with in the movie clip size.
I am sure this may be too trivial but being a newbie in flash/AS3, its looks impossible to be at this point and I urgently need it to finish my college project. Any sample code will be great!

TIA
Reply