I used the Photo Gallery tutorial found at http://www.kirupa.com/developer/mx/photogallery.htm to create a slideshow. However, it’s not bringing up the pictures. I chose not to use the buttons so I’m assuming the pictures fade in and fade out automatically. Am I right to assume this? Here’s the code I’ve got, it’s the same as what is in the tutorial except for the folder and the filenames. Was I supposed to change anything else?
Thanks for your help!
// put the path to your pics here, include the slashes (ie. “pics/”)
// leave it blank if they’re in the same directory
this.pathToPics = “”;
// fill this array with your pics
this.pArray = [“cdc.gif”, “denmark_royalty_library.gif”, “navy.gif”, “niehs.gif”, “saic.gif”, “san_diego.gif”, “shell.gif”, “standards_council_canada.gif”, “three_valleys.gif”, “tmobile.gif”, “us_census_bureau.gif”];
this.fadeSpeed = 20;
this.pIndex = 0;
// MovieClip methods ----------------------------------
// d=direction; should 1 or -1 but can be any number
//loads an image automatically when you run animation
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
MovieClip.prototype.changePhoto = function(d) {
// make sure pIndex falls within pArray.length
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() {
// specify the movieclip to load images into
var p = _root.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;
} 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;
}
};
But no other functions are being called…
To get what you’re after you have to use setInterval() (look it up in your AS dictionary;) ).
In your case put
setInterval(this, "changePhoto", 5000, 1);
at the bottom of your code, the 5000 are in msecs:)
Thanks Scotty,
I’m pretty new at all this, was I supposed to put setInterval right under loadMovie? Also, for some reason, not even the first image loads when I test the movie. Do you know why that could be?
One last question, this is pickiness on my part. when each image fades in and out it shifts about 1 pixel to the right then when it’s in place, it shifts about one pixel to the left.
Ive pretty much followed the directions of the tutorial, but decided to test it out with 2 pictures… but when I press on the arrow buttons I have created, the word ‘NaN’ repeatedly traces.
I have no idea what to make of it, as i dont have that word/letters anywhere on my code.
Any ideas?
Thanks
this.pathToPics = "";
this.pArray = ["shoes.jpg", "ITALYtivoli.jpg"];
this.fadeSpeed = 20;
this.pIndex = 0;
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
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() {
// specify the movieclip to load images into
var p = _root.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;
} 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;
}
};
Making this for my website, and the slide show work graet and simple.
However, I am trying to make a Play button and pause button so the user can pause at something by looking at it.
I have created 2 buttons, one pause and one play.
I know the code involves
I am also having some trouble getting any pictures to show up. I am pretty sure that none of my jpgs are progressive. I still just get my grey box instead of pictures. Can anyone figure this out?