# XML Gallery thumb Spacing

**URL:** <https://forum.kirupa.com/t/xml-gallery-thumb-spacing/165102>\
**Category:** flash\
**Created:** [October 7, 2005, 5:37pm UTC](https://forum.kirupa.com/t/xml-gallery-thumb-spacing/165102 "2005-10-07T17:37:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grimshaw](https://avatars.discourse-cdn.com/v4/letter/g/439d5e/32.png) [@Grimshaw](https://forum.kirupa.com/u/Grimshaw)\
**Post date:** [October 7, 2005, 5:37pm UTC](https://forum.kirupa.com/t/xml-gallery-thumb-spacing/165102/1 "2005-10-07T17:37:27Z")

</div>

Below is the code for kirupas gallery portfolio xml app. My question is, Is there any way to calculate the thumb\_spacing var from the actual width of the picture rather than defining it as var thumb\_spacing = 40;. This way you could have thumbnails with different widths. and not have them overlap. THanks.

```auto

var thumb_spacing = 40;

// load variables object to handle loading of text
var description_lv = new LoadVars();
description_lv.onData = function(raw_text){
	description_txt.text = raw_text;
}

function GeneratePortfolio(portfolio_xml){
	var portfolioPictures = portfolio_xml.firstChild.childNodes;
	for (var i = 0; i < portfolioPictures.length; i++){
		var currentPicture = portfolioPictures*;
		
		var currentThumb_mc = menu_mc.createEmptyMovieClip("thumbnail_mc"+i,i);
		currentThumb_mc._x = i * thumb_spacing;
		
		currentThumb_mc.createEmptyMovieClip("thumb_container",0);
		currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
		
		currentThumb_mc.title = currentPicture.attributes.title;
		currentThumb_mc.image = currentPicture.attributes.image;
		currentThumb_mc.description = currentPicture.attributes.description;
		
		
		currentThumb_mc.onRollOver = currentThumb_mc.onDragOver = function(){
			info_txt.text = this.title;
		}
		currentThumb_mc.onRollOut = currentThumb_mc.onDragOut = function(){
			info_txt.text = "";
		}
		currentThumb_mc.onRelease = function(){
			image_mc.loadMovie(this.image);
			description_lv.load(this.description);
		}
	}
}

// xml object for xml content (defines sources for selections)
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success){
	if (success) GeneratePortfolio(this);
	else trace("Error loading XML file"); // no success? trace error (wont be seen on web)
}
// load
portfolio_xml.load("portfolio.xml");
   
	

```
