PDA

View Full Version : Customizing the Photo Gallery Code


brooklyniteOne
08-06-2003, 04:00 PM
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.

kode
08-06-2003, 05:47 PM
this.randomPhoto = function() {
this.pIndex = Math.floor(Math.random()*pArray.length);
this.onEnterFrame = fadeOut;
};
interval = setInterval(this, "randomPhoto", 10000);
That code would load a random image every 10 seconds...

lostinbeta
08-06-2003, 07:02 PM
Or just tack this at the end of the script on the frame...

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

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)

brooklyniteOne
08-06-2003, 07:11 PM
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?

kode
08-06-2003, 07:29 PM
Just to make this clear... you can stop both functions, it's exactly the same thing.
// lost's code
clearInterval(myInterval);
// my code
clearInterval(interval);
And lost, http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18648. :P ;)

lostinbeta
08-06-2003, 08:02 PM
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?

kode
08-06-2003, 08:04 PM
Probably because he (he, right?) said random image. :P

lostinbeta
08-06-2003, 08:06 PM
bah... that I missed :(

var me = idiot = true

kode
08-06-2003, 08:11 PM
Come on... :sigh:

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

lostinbeta
08-06-2003, 08:15 PM
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)

julietling
06-01-2004, 10:52 PM
i'm very very new to actionscript, i'm not doin a slideshow but a photogallery (just exactly like the tutorial) with thumbnail buttons that when click show the individual photo.

I was wondering is there a way I can modify the script in the Photo Gallery tutorial so that the images crossfade each other and not fully fade out then fade in.

thank you for your time.

ling

sprite
07-12-2004, 03:09 PM
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

herbiblak
07-17-2004, 02:16 PM
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.

riguetti
09-06-2004, 04:00 PM
is possible to place one preload before each photo?
How I make this?

thanks e sorry for bad english...

emolen
09-16-2004, 09:10 PM
herbiblak- did you ever get an answer to that elsewhere??
I would love to know and do the same
erok

stikigekko
10-13-2004, 01:04 PM
I set up this photogallery and it works, but anytime I move to a different frame I get a neverending output of NaN. I imagine I need to tell it to stop, but I am fairly new to actionscript and I am not sure how to do this.

Lostinbeta mentioned using: clearInterval(myInterval) to stop it, but I am not sure where I put this and how...

bleaks1
03-22-2005, 10:13 PM
I am running into a very irritating problem -

I have a main movie -the root if you will, that when a button is pressed it loads a different swf file into a movie clip, as demonstrated in the "full flash site" tutorial. I also wanted to integrate this photo gallery within one of the swf's... particularly my gallery swf. Bu the problem i am running into is that instead of loading the gallery into the current movie clip, it is loading it into the root movie clip and leaves out all the other neccesary objects from the called movie clip. so essentially when i run it the first image for the gallery loads on top of my original page, instead of loading inside the gallery windows with the apprpriate masking and all that.

i think this statement may be the culprit, i just dont know how to modify it correctly...

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

namely the _root.photo part of it is what i think is "short circuiting" the whole show . How can i tell the gallery movie clip to remain inside itself while running the gallery codeand not place itself on top of my main movie? do i type an alternative to the _root statement?


please please please help me... I am trying to fnish this project up tonight and this is all thats holding me back...

thanks -

_3li3_
10-18-2005, 02:49 AM
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.

aight! the code to make it move like a slideshow works fine.
And what if we want to add buttons to pause the movement or keep playing it?
Anyone?

muyrapido
07-03-2008, 04:10 PM
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>

<pic>
<image>2.jpg</image>
<caption>Caption 2</caption>
<url>/index.html</url>
<delay>3000</delay>
</pic>

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

CSS code:

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