PDA

View Full Version : xml photo gallery


dgc
08-14-2007, 11:52 PM
Hi,
I am making a site with 2 photo sections.
When the page loads, I want photos to load automatically as if viewing a slideshow.
This is working.

Then when the user clicks on a category, I want to load a photo section that DOES NOT load automatically - you would have to use arrows.

My problem is this:
The photos load automatically when the site loads, but when I click on a button to load a category, the new photos load, but they load as a slideshow too even though I don't want them to.
Hope this makes sense.
Any suggestions? Thanks so much!!!!





stop();


delay = 2000;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images1.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
//previous_btn.onRelease = function() {
//prevImage();
//};
//next_btn.onRelease = function() {
//nextImage();
//};
/////////////////////////////////////

p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};

function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 20;
picture.contentPath = image[p];
//desc_txt.text = description[p];
picture_num();
slideshow();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 20;
picture.contentPath = image[p];
//desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 20;
picture.contentPath = image[0];
//desc_txt.text = description[0];
picture_num();
slideshow();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}


menu_one_mc.onRelease = function() {
stick("menu_one_mc");
xmlData.load("myphotos.xml");
}

atomic
08-15-2007, 12:58 AM
So the above is the code for the first slideshow... What's your code to load up the second one?

dgc
08-15-2007, 04:13 AM
Here's the code for the second. I'm new to xml, and don't know how to adapt this code.
Thanks so much for helping!



function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
//xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}

atomic
08-15-2007, 07:06 AM
Are you saying that the first one autoplays, and that you just don't want the second one to do so, but have the user hit the arrows to actually play it?

dgc
08-15-2007, 01:10 PM
Yes, I want the site to load with an autoplay slideshow, then there will be 3 categories of photo galleries. If you click on any of the 3 categories, they will load a gallery that DOES NOT autoplay - they're will be next / previous arrows. Thanks so much for your help!!!!!!!

atomic
08-15-2007, 02:24 PM
Ok... Last question. Do you want the first picture of those 3 categories to at least load, or should the screen remain blank until the arrow is hit?

dgc
08-15-2007, 02:27 PM
I want the first photo to load for each category - then use arrows to get to 2nd, 3rd etc.

atomic
08-15-2007, 04:54 PM
Well removing the slideshow(); function in the firstImage() & nextImage() functions, as you have done, should be giving you what you want, or at least it does for me...

If it still doesn't work, then you should probably attached your .fla, to see what else is keeping it from working...

dgc
08-15-2007, 05:02 PM
can't get it to work....
I uploaded the file via ftp (to big to post)

ftp.fatcow.com
username: jordanh
password: jordanh

atomic
08-15-2007, 05:06 PM
Having a look now...

atomic
08-15-2007, 05:19 PM
I don't get it?

The first gallery loads up with the first picture (kid), but doesn't autoplay...
You need to press the arrows or keys to change picture...
So what's the problem?

Are you talking about a previous autoplaying slideshow, before this is loaded up?

atomic
08-15-2007, 05:33 PM
Or should this first slideshow, the one with the kid as first picture, be autoplaying and when you hit People, it should load the business non autoplaying one... I'm missing something!

And what's loadCategory(1); supposed to be doing?

dgc
08-15-2007, 09:02 PM
Sorry! I didn't realize you got back to me.
I was in such a hurry to FTP you the files that I forgot to change a couple of things back.
I am sooooo sorry! I really appreciate your help.
This should make more sense now...
The pages loads with the correct slideshow, then when you click on "people", I want the photos to only be seen using arrows.


I re-uploaded it to the same FTP:

ftp.fatcow.com

username: jordanh
password: jordanh

atomic
08-16-2007, 06:24 AM
Ok. Got it to work, by changing and/or adding the bolded code that follows...
I also disabled the arrow keys on the autoplaying first slideshow.
Otherwise, if you want to keep the arrow keys working, you'll have to modify your code to clear your interval when you hit them keys...

First changes(BOLDED)...

//-------------BUTTONS ON RELEASE-------------------//

var auto_dsbl:Boolean = false;

menu_one_mc.onRelease = function() {
clearInterval(myInterval);
auto_dsbl = true;
stick("menu_one_mc");
//loadCategory(1);
//myPicLoader._visible = false;
//picture._visible = false;
xmlData.load("images1.xml");
//slideshow.enabled = false;

//picture.unloadMovie();
//activateThumbnails(true);
//_root.up._visible = true;
//_root.down._visible = true;
//_root.lines_mc._visible = true;
//_root.caption_mc._visible = true;
//_root.arrow_lt_mc._visible = true;
//_root.arrow_rt_mc._visible = true;
//_root.thumbHolder._visible = true;
//fadeoff();
//if (outline_mc.stat == "released") {
//outline_mc.stat = "out";
//outline_mc.gotoAndPlay("out");
//}
};
...

Second changes in the other script...

...
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if(auto_dsbl){
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
}
};
Key.addListener(listen);

...


function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 20;
picture.contentPath = image[p];
//desc_txt.text = description[p];
picture_num();
if(!auto_dsbl){
slideshow();
}
}
}
};

...

function firstImage() {
if (loaded == filesize) {
picture._alpha = 20;
picture.contentPath = image[0];
//desc_txt.text = description[0];
picture_num();
if(!auto_dsbl){
slideshow();
}
}
};

That's it... Keep me posted!

If it doesn't work out, I can probably upload my folder to your FTP.

dgc
08-16-2007, 12:54 PM
IT WORKS!!!!!!!!!!!!!!
I really can't thank you enough for all of your time!!!!
Thanks sooooooo much and have an excellent day!

atomic
08-16-2007, 04:07 PM
Grrrrrrrrrrrrrrrrreat! ;)

dgc
08-16-2007, 04:13 PM
Thanks again! You made my day!!!!

atomic
08-16-2007, 04:15 PM
Going in for a presentation myself...
Hopes it works out as well as it did for you! :eek: