# Controlling Flash buttons through XML

**URL:** <https://forum.kirupa.com/t/controlling-flash-buttons-through-xml/245472>\
**Category:** Uncategorized\
**Created:** [November 30, 2007, 1:26am UTC](https://forum.kirupa.com/t/controlling-flash-buttons-through-xml/245472 "2007-11-30T01:26:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pivotal76](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@pivotal76](https://forum.kirupa.com/u/pivotal76)\
**Post date:** [November 30, 2007, 1:26am UTC](https://forum.kirupa.com/t/controlling-flash-buttons-through-xml/245472/1 "2007-11-30T01:26:05Z")

</div>

I’m sure this topic has been beaten to death, and I’ve searched for topics for like an hour and a half. I can’t seem to figure this out. Any help would be appreciated.

I have the usual setup, XML file and Flash movie with a button called prodLink\_btn to be controlled through the XML file.

I’ve gotten it to work with loading as many images as I want, and the random loading image works great. I’m just having a problem being able to control the button link for each image I’m loading.

Here is my XML code: (i’ll be adding more images later)

[COLOR=“Red”]\<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
\<images\>  
\<pic\>  
\<image\>images/1\_1.jpg\</image\>  
\<url\>[http://paisleymonkey.com/ProductID=683](http://paisleymonkey.com/ProductID=683)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/1\_2.jpg\</image\>  
\<url\>[http://paisleymonkey.com/ProductView.aspx?ProductID=579](http://paisleymonkey.com/ProductView.aspx?ProductID=579)\</url\>  
\</pic\>  
\</images\>[/COLOR]

And my ActionScript:

```auto
delay = 5000;
//-----------------------
function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		url = [];
		description = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
			url* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
			}
		randomImage();
	} 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) {
		preloader.preload_bar._xscale = 100*loaded/filesize;
		} else {
		preloader._visible = false;
		if (picture._alpha<100) {
			picture._alpha += 10;
		}
	}
};

function randomImage() {
	p = Math.floor(Math.random()*total);
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[p]);
		prodLink_btn = url[p];
		slideshow();
		}	
}	

function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		prodLink_btn = url[p];
		slideshow();
		}
}

function nextImage() {
	if (p<(total-1)) {
		p++;
		if (loaded == filesize) {
			picture._alpha = 0;
			picture.loadMovie(image[p], 1);
			prodLink_btn = url[p];
			slideshow();
			}
	}
}

function slideshow() {
	myInterval = setInterval(pause_slideshow, delay);
	function pause_slideshow() {
		clearInterval(myInterval);
		if (p == (total-1)) {
			p = 0;
			firstImage();
		} else {
			nextImage();
		}
	}
	}

```

I’ve tried to find examples to adapt to mine, but I just can’t figure it out. I’m pounding my head on the desk. Any help would be greatly appreciated. Thank you all!

---

<div class="post-metadata">

**Author:** ![ero\_sennin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ero_sennin/32/3747_2.png) [@ero\_sennin](https://forum.kirupa.com/u/ero_sennin)\
**Post date:** [June 24, 2008, 3:19pm UTC](https://forum.kirupa.com/t/controlling-flash-buttons-through-xml/245472/2 "2008-06-24T15:19:55Z")

</div>

Yea I would also very much like to hear how you solved this?
