# Photo Gallery question

**URL:** https://forum.kirupa.com/t/photo-gallery-question/119828
**Category:** Uncategorized
**Created:** [August 18, 2004, 12:22pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828 "2004-08-18T12:22:59Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mstern02](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mstern02](https://forum.kirupa.com/u/mstern02)
#### Post date: [August 18, 2004, 12:22pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/1 "2004-08-18T12:22:59Z")

</div>

I used the Photo Gallery tutorial found at [http://www.kirupa.com/developer/mx/photogallery.htm](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;  
}  
};

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 18, 2004, 12:51pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/2 "2004-08-18T12:51:02Z")

</div>

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

```auto
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

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

```

at the bottom of your code, the 5000 are in msecs:)

scotty(-:

---

<div class="post-metadata">

### Author: ![mstern02](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mstern02](https://forum.kirupa.com/u/mstern02)
#### Post date: [August 18, 2004, 12:57pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/3 "2004-08-18T12:57:15Z")

</div>

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?

> [@scotty](#):
>
> The code as you have it now will only show the first picture because of this line
> 
> ```auto
> 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
> 
> ```auto
> setInterval(this, "changePhoto", 5000, 1);
> 
> ```
> 
> at the bottom of your code, the 5000 are in msecs:)
> 
> scotty(-:

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 18, 2004, 1:03pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/4 "2004-08-18T13:03:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 18, 2004, 1:07pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/5 "2004-08-18T13:07:36Z")

</div>

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

scotty(-:

---

<div class="post-metadata">

### Author: ![mstern02](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mstern02](https://forum.kirupa.com/u/mstern02)
#### Post date: [August 18, 2004, 1:26pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/6 "2004-08-18T13:26:31Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 18, 2004, 1:58pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/7 "2004-08-18T13:58:14Z")

</div>

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

```auto
this.photo._alpha = 98;

```

scotty(-:

---

<div class="post-metadata">

### Author: ![mstern02](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mstern02](https://forum.kirupa.com/u/mstern02)
#### Post date: [August 18, 2004, 2:03pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/8 "2004-08-18T14:03:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [August 18, 2004, 2:07pm UTC](https://forum.kirupa.com/t/photo-gallery-question/119828/9 "2004-08-18T14:07:40Z")

</div>

no problem=) and welcome to kirupaforum btw;)

scotty(-:
