# Photo Gallery - Please Help!

**URL:** https://forum.kirupa.com/t/photo-gallery-please-help/16580
**Category:** flash
**Created:** [March 26, 2003, 1:58pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580 "2003-03-26T13:58:46Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Sentry43](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Sentry43](https://forum.kirupa.com/u/Sentry43)
#### Post date: [March 26, 2003, 1:58pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/1 "2003-03-26T13:58:46Z")

</div>

Regarding the Photo Gallery tutorial…

I’ve used it, and it works just fine…  
But…I don’t want to use buttons…or key presses (like at the end of the code)  
I want a continuos loop…through all my pictures.

How do I do that?  
Please Help…I need this yesterday!:sure:

Thanks

Here’s the current code.  
[AS]  
//Code written by sbeener (suprabeener)  
/\*  
i wrote this code, but you can use and abuse it however you like.  
the methods are defined in the order which they occur to make it  
easier to understand.  
\*/  
// variables ------------------------------------------  
// 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 = [“BO1.jpg”, “GeGe2.jpg”, “HEATHER3.jpg”, “JAMES4.jpg”, “JEN5.jpg”, “KENNIE6.jpg”, “MEL7.jpg”, “Nicole8.jpg”, “TAMMY9.jpg”, “TOM10.jpg”];  
this.fadeSpeed = 10;  
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;  
}  
};

// Actions -----------------------------------------  
// these aren’t necessary, just an example implementation  
[//this.onKeyDown](https://this.onKeyDown) = function() {  
//if (Key.getCode() == Key.LEFT) {  
// this.changePhoto(-1);  
// } else if (Key.getCode() == Key.RIGHT) {  
// this.changePhoto(1);  
// }  
//};  
[//Key.addListener](https://Key.addListener)(this);  
[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 2:25pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/2 "2003-03-26T14:25:29Z")

</div>

```auto
aChange = function(i) {
i.changePhoto(1);
};
setInterval(aChange, milliseconds, this);

```

just change **milliseconds** to the time you want 😉 =)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 2:45pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/3 "2003-03-26T14:45:34Z")

</div>

me again… 😛

now that i think about it, you don’t need that code.

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

```

would do… :sigh:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 6:28pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/4 "2003-03-26T18:28:28Z")

</div>

Thanks for the help!

Worked great!

Although it worked fine with your first post…didn’t try the second suggestion:sigh:  
…what’s the difference?

Also, If I wanted to make each image a button, to where …when clicked…it would load a .swf …like a bio or something…any suggestions?

Again Thanks!!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 6:45pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/5 "2003-03-26T18:45:58Z")

</div>

there’s no real difference between them… less coding. that’s all 😉

and i didn’t test this… but i think you’d need to assign the even handler in this prototype

```auto
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
this.photo.onRelease = function() {
statement(s);
}
}
}

```

=)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 9:50pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/6 "2003-03-26T21:50:13Z")

</div>

KAX…  
Thanks for all your help…

I having fits with the button thingy.

Basically, I’ve created one button…with just a “hit” action so it’s invisible.  
It’s on a layer above my photos.

Is there a way…to load a seperate movie on the click of the button…based on what photo is showing?

This is driving me nuts!

Thanks in advance.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 26, 2003, 10:46pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/7 "2003-03-26T22:46:06Z")

</div>

i guess you can store the name of the movies in an array. then use the variable pIndex to load the content… =)

something like this:

```auto
movies = ["BO1.swf", "GeGe2.swf", "HEATHER3.swf"];
myButton.onRelease = function() {
myMovieClip.loadMovie(movies[pIndex]);
}

```

😉

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 3:43am UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/8 "2003-03-27T03:43:08Z")

</div>

I’m trying to do the same thing…  
And I’m getting these errors:

[AS]  
Scene=Scene 1, Layer=Layer 25, Frame=1: Line 1: Statement must appear within on handler  
movies = [“bo1.swf”, “gege2.swf”, “heather3.swf”, “james4.swf”, “jen5.swf”, “kennie6.swf”, “mel7.swf”, “nicole8.swf”, “tammy9.swf”, “tom10.swf”];

Scene=Scene 1, Layer=Layer 25, Frame=1: Line 2: Statement must appear within on handler  
myButton.onRelease = function() {[/AS]

Any help???

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 7:29am UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/9 "2003-03-27T07:29:03Z")

</div>

put the script in the timeline… not in the button actions 😉 =)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 12:34pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/10 "2003-03-27T12:34:43Z")

</div>

hmmm…I’m trying to load the .swf into a emtpy movie clip on the stage…

I moved the code to the timeline…but nothing happens…no errors…nothing.

sorry for all the questions…but how does it know “which” button I’ve pressed? and where is it stated in the “AS” to load the movie into a movie clip?

\*I"m confused…as usual \*😏

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 1:17pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/11 "2003-03-27T13:17:35Z")

</div>

> but how does it know “which” button I’ve pressed?

**myButton** is the instance name of the button. of course you can change it to whatever you want.  
if the instance name of your button is **abc** … then replace myButton with abc

> where is it stated in the “AS” to load the movie into a movie clip?

```auto
myMovieClip.loadMovie(movies[pIndex]);

```

again… replace myMovieClip with the instance name of your movie clip.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 2:34pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/12 "2003-03-27T14:34:13Z")

</div>

**Kax…you are the greatest!**

That works great!

thanks for the help man…I really appreciate it.

:beam:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 27, 2003, 2:39pm UTC](https://forum.kirupa.com/t/photo-gallery-please-help/16580/13 "2003-03-27T14:39:59Z")

</div>

😛

no problem =)
