Hi all, i’ve been trying to work with this actionscript to make it random and i just can’t seem to do it. Any direction would be greatly appreciated.
var id, current;
var k = 0, p = 0;
var slide = 1;
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;
}
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("assets/flash/splash/images.xml");
function Math.preloadPic()(Math.random()*5) {
clearInterval(id);
var con = picture.duplicateMovieClip("con"+k, 200+k);
con.loadMovie(image[p]);
_root.txt.desc_text_mov.desc_txt.text = description[p];
preloader._visible = 1;
con._alpha = 0;
var temp = picture.createEmptyMovieClip("temp"+k, 99+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
_root.txt.gotoAndPlay(2);
if (slide) {
id = setInterval(nextImage, 9000);
}
delete this.onEnterFrame;
}
};
}
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};
function nextImage() {
current = this["con"+p];
p<total-1 ? p++ : p=0;
preloadPic();
}
function prevImage() {
current = this["con"+p];
p>0 ? p-- : p=total-1;
preloadPic();
}
preloadPic();