Hi there,
Firstly I just wanted to say thanks for writing the tutorial “Create a Photo Gallery”. I found it very helpful, but I have a small problem which I cant seem to figure out a solution to. I’m sure its something simple, but if someone could help that would be much appreciated.
Basically I wanted to create a flash artefact which contains multiple gallerys like the one shown in the tutorial. Each one works on its own, but when I use multiple galleries together only the last one works.
Here is some code showing 2 galleries together.
this.pathToPics = “images/gallery01/”;
this.pArray = [“image-a1.jpg”, “image-a2.jpg”, “image-a3.jpg”];
this.fadeSpeed = 20;
this.pIndex = 0;
loadMovie(this.pathToPics+this.pArray[0], _root.photo1);
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.photo1._alpha>this.fadeSpeed) {
this.photo1._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
var p = _root.photo1;
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo1.getBytesLoaded();
t = this.photo1.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo1._alpha<100-this.fadeSpeed) {
this.photo1._alpha += this.fadeSpeed;
} else {
this.photo1._alpha = 100;
this.onEnterFrame = null;
}
};
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};
Key.addListener(this);
this.pathToPics = “images/gallery02/”;
this.pArray = [“image-b1.jpg”, “image-b2.jpg”, “image-b2.jpg”];
this.fadeSpeed = 20;
this.pIndex = 0;
loadMovie(this.pathToPics+this.pArray[0], _root.photo2);
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.photo2._alpha>this.fadeSpeed) {
this.photo2._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
var p = _root.photo2;
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo2.getBytesLoaded();
t = this.photo2.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo2._alpha<100-this.fadeSpeed) {
this.photo2._alpha += this.fadeSpeed;
} else {
this.photo2._alpha = 100;
this.onEnterFrame = null;
}
};
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};
Key.addListener(this);
I have given one movie clip the instance name “photo1” and the other “photo2”… both work individually, but not together.
Can anyone see how to fix it to make it load.
Thanks in advance
Would really appreciate any help anyone could give me.