i have two blank mc’s that take images from xml and are linked to urls specified in xml as shown below.
weird thing is, mc link doesn’t work until the second image (nothing happens until the second image when clicked) and the link indexes are truncated by 2. so instead of linking to link[0], it goes to link[2] and continues incrementing from link[2]. i think it has to do with the loops but i can’t seem to find the error… can someone help please?
entire code:
[FONT=Courier New]
delay = 5000;
// Time in milliseconds
alphaIncrement = 8;
// rate at which alpha changes from 0 to 100
adIndex = 0;
adURLindex = 0;
// default
/////////////// XML Stuff
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
link = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
link* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
ads.loadMovie(image[adIndex], 1);
while (ads.getBytesLoaded() != ads.getBytesTotal()) {
trace("not loaded yet");
}
ads._alpha = 0;
changeAlpha();
} else {
content = "file not found!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("ads.xml");
/////////////////////////// Image Handler
currentAd = true;
// true if ads will be displayed; false if ads is already displayed
function changeAlpha() {
if (adIndex == (total-1)) {
adIndex = 0;
} else {
adIndex++;
}
this.onEnterFrame = function() {
if (currentAd) {
if (ads._alpha<100) {
ads._alpha += alphaIncrement;
ads2._alpha -= alphaIncrement;
} else {
currentAd = false;
ads2.loadMovie(image[adIndex], 1);
delete this.onEnterFrame;
}
} else {
if (ads2._alpha<100) {
ads2._alpha += alphaIncrement;
ads._alpha -= alphaIncrement;
} else {
currentAd = true;
ads.loadMovie(image[adIndex], 1);
delete this.onEnterFrame;
}
}
};
changeAdLink();
slideshow();
}
/////////////////////////// Slide Show
function changeAdLink() {
ads.onRelease = function() {
getURL(link[adURLindex], "_blank");
};
ads2.onRelease = function() {
getURL(link[adURLindex], "_blank");
};
what.text = link[adURLindex];
trace(link[adURLindex]);
if (adURLindex == (total-1)) {
adURLindex = 0;
} else {
adURLindex++;
}
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (currentAd) {
ads._alpha = 0;
changeAlpha();
} else {
ads2._alpha = 0;
changeAlpha();
}
}
}
[/FONT]