# Customizing the Photo Gallery Code

**URL:** https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800
**Category:** flash
**Created:** [August 6, 2003, 7:00pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800 "2003-08-06T19:00:48Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![brooklyniteOne](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@brooklyniteOne](https://forum.kirupa.com/u/brooklyniteOne)
#### Post date: [August 6, 2003, 7:00pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/1 "2003-08-06T19:00:48Z")

</div>

Using the tutorial found on this site here:

[http://www.kirupa.com/developer/mx/photogallery.htm](http://www.kirupa.com/developer/mx/photogallery.htm)

How can I set the gallery to continuously display random images? Like a looping slideshow effect.

---

<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: [August 6, 2003, 8:47pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/2 "2003-08-06T20:47:34Z")

</div>

[AS]this.randomPhoto = function() {  
this.pIndex = Math.floor(Math.random()\*pArray.length);  
this.onEnterFrame = fadeOut;  
};  
interval = setInterval(this, “randomPhoto”, 10000);[/AS]  
That code would load a random image every 10 seconds…

---

<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: [August 6, 2003, 10:02pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/3 "2003-08-06T22:02:48Z")

</div>

Or just tack this at the end of the script on the frame…

[AS]myInterval = setInterval(this, “changePhoto”, 10000, 1);[/AS]

It creates a setInterval with the ID myInterval to run the changePhoto function every 10 seconds (10000 milliseconds). Since the changePhoto function contains a parameter to go -1 (back) or 1 (forward) the 1 in the script is the parameter to make it go forward an image.

You can stop running the slideshow via clearInterval(myInterval)

---

<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: [August 6, 2003, 10:11pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/4 "2003-08-06T22:11:45Z")

</div>

whoa thanks I had already tacked the first code by Kax after the following:

```auto

// Actions -----------------------------------------
// these aren't necessary, just an example implementation

```

And it worked great. Lostinbeta …so the advantage of using the myInterval code is that I can stop the slideshow? Is that the only advantage?

---

<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: [August 6, 2003, 10:29pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/5 "2003-08-06T22:29:58Z")

</div>

Just to make this clear… you can stop both functions, it’s exactly the same thing.  
[AS]// lost’s code  
clearInterval(myInterval);  
// my code  
clearInterval(interval);[/AS]  
And lost, [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18648](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18648). 😛 😉

---

<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: [August 6, 2003, 11:02pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/6 "2003-08-06T23:02:42Z")

</div>

Yeah, clearInterval works as clearInterval(intervalID) in kaxs’ case his intervalID was “interval” and in my case it was “myInterval”.

And OMG kax, I never saw that thread I swear!!! But my question is this, if you posted that method before, why did you post a different method this time?

---

<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: [August 6, 2003, 11:04pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/7 "2003-08-06T23:04:42Z")

</div>

Probably because he (he, right?) said _random image_. 😛

---

<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: [August 6, 2003, 11:06pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/8 "2003-08-06T23:06:32Z")

</div>

bah… that I missed ☹

var me = idiot = true

---

<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: [August 6, 2003, 11:11pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/9 "2003-08-06T23:11:20Z")

</div>

Come on… :sigh:

If you’re an idiot, then I’m an idiot too because I misread posts all the time. 😛

---

<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: [August 6, 2003, 11:15pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/10 "2003-08-06T23:15:04Z")

</div>

Actually you know what… just to make myself feel better I will blame it on the Tylenol Daytime medication (my sister got me sick… grrrr), it has made me dizzy/woozy all day (although that wasn’t my problem here I will just blame it on that anyway)

---

<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: [July 12, 2004, 6:09pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/11 "2004-07-12T18:09:51Z")

</div>

Hi guys (guys?)

This setinterval works really well…until you change the fade speed. If you set the fade speed to 2 to make it really slow, the interval thing still keep rotating the image so it all goes haywire.

Any way to make the interval wait until the last image has loaded and faded up before starting the timer and then onto the next one???

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: [July 17, 2004, 5:16pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/12 "2004-07-17T17:16:09Z")

</div>

ok people,

love the Photo Gallery code. was wondering if there was a way to identify each of the images in the pArray field and then instead of using back + forward buttons having thumbnails that each point to a direct JPEG instead of just +1 or -1 what do people think?

any help would be great.

thanks.

hb.

---

<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: [September 6, 2004, 7:00pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/13 "2004-09-06T19:00:37Z")

</div>

is possible to place one preload before each photo?  
How I make this?

thanks e sorry for bad english…

---

<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: [September 17, 2004, 12:10am UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/14 "2004-09-17T00:10:46Z")

</div>

herbiblak- did you ever get an answer to that elsewhere??  
I would love to know and do the same  
erok

---

<div class="post-metadata">

### Author: ![muyrapido](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@muyrapido](https://forum.kirupa.com/u/muyrapido)
#### Post date: [July 3, 2008, 7:10pm UTC](https://forum.kirupa.com/t/customizing-the-photo-gallery-code/27800/15 "2008-07-03T19:10:32Z")

</div>

Is it possible to link the captions from the xml to a textArea and then format it with css? I have the text displaying, but I don’t the style sheet is not being read.

If you’ve tried this, I’d love to know. Thanks!

Flash code:  
//init TextArea component  
myTextCaption.html = true;  
myTextCaption.wordWrap = true;  
myTextCaption.multiline = true;  
myTextCaption.label.condenseWhite=true;

//load css  
captionStyle = new TextField.StyleSheet();  
captionStyle.load(“captionStyle.css”);  
myTextCaption.styleSheet = captionStyle;

xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.load(“images.xml”);  
xmlData.onLoad = loadXML;

XML code:

\<images\>  
\<pic\>  
\<image\>1.jpg\</image\>  
\<caption\>Caption 1\</caption\>  
\<url\>/index.html\</url\>  
\<delay\>3000\</delay\>  
\</pic\>

```
&lt;pic&gt;
    &lt;image&gt;2.jpg&lt;/image&gt;
&lt;caption&gt;Caption 2&lt;/caption&gt;
&lt;url&gt;/index.html&lt;/url&gt;
&lt;delay&gt;3000&lt;/delay&gt;
&lt;/pic&gt;

&lt;pic&gt;
    &lt;image&gt;3.jpg&lt;/image&gt;
&lt;caption&gt;Caption 3&lt;/caption&gt;
&lt;url&gt;/index.html&lt;/url&gt;
&lt;delay&gt;3000&lt;/delay&gt;
&lt;/pic&gt;

```

\</images\>

CSS code:

caption {  
color: #FF0000;  
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;  
font-size: 14px;  
font-weight: normal;  
display: block;  
}
