# Dynamically Resize Movieclip

**URL:** <https://forum.kirupa.com/t/dynamically-resize-movieclip/195546>\
**Category:** flash\
**Created:** [August 1, 2006, 3:16pm UTC](https://forum.kirupa.com/t/dynamically-resize-movieclip/195546 "2006-08-01T15:16:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evilcoathanger](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@evilcoathanger](https://forum.kirupa.com/u/evilcoathanger)\
**Post date:** [August 1, 2006, 3:16pm UTC](https://forum.kirupa.com/t/dynamically-resize-movieclip/195546/1 "2006-08-01T15:16:31Z")

</div>

Hey guys, question for ya. I’m looking for a way to load an image through XML, and resize it to fit to a certain box size I specify.

Heres what I have so far:

```auto
/////////////////////////
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("test.xml");
//////////////////////////////////////
function firstImage() {
var maxWidth = 200;
//original width of container
var maxHeight = 100;
//original height of container
container_mc.loadMovie(image[0], 1);
if (container_mc._width>=200) {
var ctnrWidth = container_mc._width;
// Calculate percentage by which image will need to change to fit 
scalePercent = (ctnrWidth>maxWidth) ? maxWidth*100/ctnrWidth : scalePercent;
container_mc._xscale = scalePercent;
}
if (container_mc._height>=100) {
var ctnrHeight = container_mc._height;
// Calculate percentage by which image will need to change to fit
scalePercent = (ctnrHeight>maxHeight) ? maxHeight*100/ctnrHeight : scalePercent;
container_mc._yscale = scalePercent;
}
}
/////////////////////////

```

Thanks in advance.

**EDIT:** Removed Broken URL
