I’m working on a variation of the photo gallery tutorial, and I’ve been trying to specify random effects on a movie clip which is dynamically loading photos. I tried using the idea of the randomly loading backgrounds to specify panning effects, except that flash is running several of them on each photo instead of one case to each time a new photo loads.
Here is the script, without the random effects…
thanks in advance.
[AS]
var absX = Stage.width/2;
var absY = Stage.height/2;
this.pathToPics = “”;
this.pArray = [“1.jpg”, “2.jpg”, “3.jpg”, “4.jpg”, “5.jpg”, “6.jpg”, “7.jpg”, “8.jpg”, “9.jpg”, “10.jpg”];
this.fadeSpeed = 20;
this.pIndex = 0;
//loading en setting x/y for first picture
loadMovie(this.pathToPics+this.pArray[0], this.photo);
this.photo._x = absX-180;//first picture = 360 width/2
this.photo._y = absY-117.5;//first picture = 235 height/2
MovieClip.prototype.changePhoto = function(d) {
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 i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
this.photo._x = absX-this.photo._width/2;
this.photo._y = absY-this.photo._height/2;
} else {
//trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
//change photo with keys
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
change = 0;
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
change = 0;
}
};
Key.addListener(this);
//autoplay
var autoplay = true, change = 0;
this.createEmptyMovieClip(“container”, 1000);
container.onEnterFrame = function() {
if (autoplay && change++>=25) {
changePhoto(1);
change = 0;
}
};
//play button
play.onPress = function() {
autoplay = true;
};
//pause button
pause.onPress = function() {
autoplay = false;
};
[/AS]