i just created an image gallery. i used the kirupa tutorial as a rough guideline, so i changed up a few things. it works fine. im wanting to use the xml file as a config file, but that part is not working.
heres my xml code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<gallery textcolor="0x999999" bgcolor="0x000000">
<image url="http://home.comcast.net/~urtalkinstupid/image1.jpg" caption="OMG! dude has peanut butter on his nose!"/>
<image url="http://home.comcast.net/~urtalkinstupid/image2.jpg" caption="he wouldnt be quiet; we had to do it."/>
<image url="http://home.comcast.net/~urtalkinstupid/image3.jpg" caption="philip and i found these ****ing awesome bracelets"/>
<image url="http://home.comcast.net/~urtalkinstupid/image4.jpg" caption="my finger didnt want to go to work with me. it slammed itself in the door"/>
<image url="http://home.comcast.net/~urtalkinstupid/image5.jpg" caption="OMG! the dolphin is a whore."/>
<image url="http://home.comcast.net/~urtalkinstupid/image6.jpg" caption="yea, theres nothing to do at the library. read!"/>
</gallery>
does anyone know how to parse the attributes in the gallery part. ive tried a lot of as coding, but i always get “undefined” as an output.
i guess ill put my as code here also (i took the code stuff that i tried out):
import mx.utils.Delegate;
index = 0;
galleryXML = new XML();
XMLSource = "http://home.comcast.net/~urtalkinstupid/photogallery.xml"
galleryXML.ignoreWhite = "true"
images = new Array();
galleryXML.load(XMLSource);
galleryXML.onLoad = function(success){
if (success){
allnodes = this.firstChild.childNodes
total = allnodes.length;
for(i=0; i<allnodes.length; i++){
images.push({url:allnodes*.attributes.url,caption:allnodes*.attributes.caption});
}
}
firstImage();
}
this.onEnterFrame = function(){
filesize = picture_mc.getBytesTotal();
loaded = picture_mc.getBytesLoaded();
preloader_mc._visible = true;
if(loaded != filesize){
preloader_mc.loadbar_mc._xscale = 100*loaded/filesize;
}else {
preloader_mc._visible = false;
if(picture_mc._alpha<100){
picture_mc._alpha += 10;
}
}
}
function nextImage(){
if(index < (total-1)){
index++;
if(loaded == filesize){
picture_mc._alpha = 0;
picture_mc.loadMovie(images[index].url, 1);
caption_txt.text = images[index].caption
picture_num();
}
}
}
function prevImage(){
if(index > 0){
index--;
picture_mc._alpha = 0;
picture_mc.loadMovie(images[index].url, 1);
caption_txt.text = images[index].caption;
picture_num();
}
}
function firstImage(){
if(loaded == filesize){
picture_mc._x = 100;
picture_mc._y = 75;
picture_mc._alpha = 0;
picture_mc.loadMovie(images[0].url);
caption_txt.text = images[0].caption;
picture_num();
}
}
function picture_num(){
current_pos = index + 1;
pos_txt.text = current_pos+ " / " +total;
}
next_mc.onRelease = Delegate.create(this, nextImage);
previous_mc.onRelease = Delegate.create(this, prevImage);
any help is highly appreciated. thanks in advance.