Customizing the Photo Gallery Code

Using the tutorial found on this site here:

http://www.kirupa.com/developer/mx/photogallery.htm

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

[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…

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)

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



// 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?

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. :stuck_out_tongue: :wink:

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?

Probably because he (he, right?) said random image. :stuck_out_tongue:

bah… that I missed :frowning:

var me = idiot = true

Come on… :sigh:

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

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)

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

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.

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

thanks e sorry for bad english…

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

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