Hi All,
I’m trying to figure out how to make my photo gallery load the images randomly each time. I’m a beginner at flash so don’t know too much about actionscript. If someone could take a look at my code and tell me how to modify it to do this, that would be great! Thanks so much!
my actionscript:
this.pathToPics = "[http://www2.cybergolf.com/sites/images/347/](http://www2.cybergolf.com/sites/images/347/)";
this.pArray = ["winchester.jpg", "aliante.jpg", "angelpark.jpg", "dalhousie.jpg", "theduke.jpg", "highmeadowranch.jpg", "indianwells.jpg", "lagunadelmar.jpg", "thelegacy.jpg", "lincolnhills.jpg", "longbow.jpg", "phantomhills.jpg", "sandia.jpg", "somerby.jpg", "threecrowns.jpg", "tijerascreek.jpg", "wekopa.jpg"];
this.fadeSpeed = 20;
this.pIndex = 0;
MovieClip.prototype.changePhoto = function(d) {
clearInterval(id);
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
var p = this.photo;
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
id = setInterval(this, "changePhoto", 10000, 1);
this.onEnterFrame = null;
}
};
//start everything
changePhoto(0);