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</url>
</pic>
<pic>
<image>images/1_2.jpg</image>
<url>http://paisleymonkey.com/ProductView.aspx?ProductID=579</url>
</pic>
</images>[/COLOR]
And my ActionScript:
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!