# Scaling a image in Flash

**URL:** <https://forum.kirupa.com/t/scaling-a-image-in-flash/19131>\
**Category:** Uncategorized\
**Created:** [April 24, 2003, 3:33pm UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131 "2003-04-24T15:33:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![7of9](https://avatars.discourse-cdn.com/v4/letter/7/c89c15/32.png) [@7of9](https://forum.kirupa.com/u/7of9)\
**Post date:** [April 24, 2003, 3:33pm UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131/1 "2003-04-24T15:33:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 24, 2003, 3:51pm UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131/2 "2003-04-24T15:51:29Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 24, 2003, 8:12pm UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131/3 "2003-04-24T20:12:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 11:48am UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131/4 "2003-04-25T11:48:53Z")

</div>

scalex and scaley work on percentages!  
Be sure to change the size AFTER you load a new pic!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 4:33pm UTC](https://forum.kirupa.com/t/scaling-a-image-in-flash/19131/5 "2003-04-25T16:33:34Z")

</div>

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 &gt; wMax || img_mc._height &gt; hMax) 
 {
	//which dimension is the most oversized
	wDiff = img_mc._width - wMax;
	hDiff = img_mc._height - hMax;
	//calculate ratio
	if(wDiff &gt; 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;	

```

};
