Photo Gallery question

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;
}
};

The code as you have it now will only show the first picture because of this line

loadMovie(this.pathToPics+this.pArray[0], _root.photo);

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:)

scotty(-:

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?

Aah silly me:stunned:
You can’t load gifs dynamically, just jpegs…
And that code (the setInterval) at the bottom (the end) of all your code:)

scotty(-:

And, if you resave them as jpg, be sure you save them as non-progressive;)

scotty(-:

Wow, that worked very well. Thanks sooooo much!!!

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.

Could that just be the position of the movie?

No it’s Flash;)
Try setting the final alpha to 99 or 98…
So in the fadeIn prototype after the else statement

this.photo._alpha = 98;

scotty(-:

yeah, that worked!! thanks, you’ve been very helpful, i really appreciate it.

no problem=) and welcome to kirupaforum btw;)

scotty(-:

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;
 }
 };

 trace(l/t);

Take this line out or comment it (’//’)

scotty(-:

thank you, it has stopped tracing randomness…

although i have arrow buttons that work, the pictures continue to load, like an automated slide show.

But your pictures do load?
Can you post your .fla?

scotty(-:

ah nevermind, i had added the bit of code you had suggested to the last person, which was causing the automated slideshow.

the pictures (though weirdly cropped by my mask) and buttons work now. thank you!

is there any simple photo gallery w/ thumbnail tutorial that doesnt need XML?

if not, does the XML code mentioned in the kirupa tutorial go in the actions box?

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

on (release) {
stop ();
}"

and

On (release {
start();
}

but it doesn’t seem to be working.

Please help…

and is it possible to set out the _x,_y of the image in this AS?
thanx in adv.

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?

http://www.ryancopeland.com/index.fla

@ layin: change this line

setInterval(this, "changePhoto", 5000, 1);

in

myInterval = setInterval(this, "changePhoto", 5000, 1);

then for your stop button and play button (code in the actions layer)


play_btn.enabled = 0;
stop_btn.onRelease = function(){
   clearInterval(myInterval)
   play_btn.enabled = 1;
}
play_btn.onRelease = function(){
   this.enabled =0;
   myInterval = setInterval(this, "changePhoto", 5000, 1);
}

scotty(-:

@ drake0013: your paths are wrong, in line 11 and 29 you have '_root.photo’
change them in ‘this.photo’

scotty(-:

thanks, scotty. that fixed it right up.