# XML & Flash, getting stuff to fit in a movieclip

**URL:** <https://forum.kirupa.com/t/xml-flash-getting-stuff-to-fit-in-a-movieclip/270580>\
**Category:** flash\
**Created:** [September 11, 2008, 7:43am UTC](https://forum.kirupa.com/t/xml-flash-getting-stuff-to-fit-in-a-movieclip/270580 "2008-09-11T07:43:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiruharudo](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@Jiruharudo](https://forum.kirupa.com/u/Jiruharudo)\
**Post date:** [September 11, 2008, 7:43am UTC](https://forum.kirupa.com/t/xml-flash-getting-stuff-to-fit-in-a-movieclip/270580/1 "2008-09-11T07:43:23Z")

</div>

Hey everybody,

I’m\* sure\* it’s been discused before …but I can’t seem to be able to find it in the masses of photo gallery questions…

So here it is;

I want to load pictures/swf’s etc into flash …no problem.

However, i want them to resize _(proportionally)_ so they fit inside the movieclip holder.

I’m ok with a solution where you have to state the size in XML, aslong as they fit in the movie clip.

Is anyone willing and able to help…?

Code:

```auto

delay = 10000;

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		description = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
		}
		firstImage();
	} else {
		content = "file not loaded!";
	}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
p = 0;
this.onEnterFrame = function() {
	filesize = picture.getBytesTotal();
	loaded = picture.getBytesLoaded();
	preloader._visible = true;
	if (loaded != filesize) {
	} else {
		preloader._visible = false;
		if (picture._alpha<100) {
			picture._alpha += 10;
		}
	}
};
function nextImage() {
	if (p<(total-1)) {
		p++;
		if (loaded == filesize) {
			picture._alpha = 0;
			picture.loadMovie(image[p], 1);
			desc_txt.text = description[p];
			picture_num();
			slideshow();
		}
	}
}
function prevImage() {
	if (p>0) {
		p--;
		picture._alpha = 0;
		picture.loadMovie(image[p], 1);
		desc_txt.text = description[p];
		picture_num();
	}
}
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		desc_txt.text = description[0];
		picture_num();
		slideshow();
	}
}
function picture_num() {
	current_pos = p+1;
	pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
	myInterval = setInterval(pause_slideshow, delay);
	function pause_slideshow() {
		clearInterval(myInterval);
		if (p == (total-1)) {
			p = 0;
			firstImage();
		} else {
			nextImage();
		}
	}
}

```

And XML:

> \<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
> \<images\>  
> \<pic\>  
> \<image\>02.jpg\</image\>  
> \<caption\>plaatje 1\</caption\>  
> \</pic\>  
> \<pic\>  
> \<image\>03.jpg\</image\>  
> \<caption\>plaatje 2\</caption\>  
> \</pic\>  
> \<pic\>  
> \<image\>masking test.swf\</image\>  
> \<caption\>en een flash filmpje\</caption\>  
> \</pic\>

\</images\>
