I have an old gallery that loaded a set of pictures and swf’s from a folder using an array
arMedia = [“clip2.swf”, “image01.jpg”, “clip2.swf” … etc …];
I wanted to update this by using xml to generate that array and came up script below.
//load media paths from xml into an array for gallery or pictuers and swf files
var galleryXML:XML = new XML();
galleryXML.ignoreWhite = true;
galleryXML.onLoad = function(loaded:Boolean) {if (loaded) {
arMedia = new Array;
arMedia = XML2Array(this);
trace(arMedia);
} else {
trace("XML could not load");
}
};
galleryXML.load("gallerypaths.xml");
function XML2Array(myXML:XML) {
arXML = new Array();
var nodes:Number = myXML.firstChild.childNodes.length;
for (i = 0; i < nodes; i++) {
arXML* = myXML.firstChild.childNodes*.attributes.media;
}
return(arXML);
}
XML seems to load and when I trace ‘arMedia’ it appears the same as if I traced the orginal array. However my gallery code does not appear to be reading the array??
I am failry new to XML - is there a difference in the way
arXML* = myXML.firstChild.childNodes*.attributes.media;
generates an element as compared with a normal array??
I’ve hunted through this forum … but I am still stumped.
Appreciate any help or suggestions
xml is very simple of the form:
<?xml version="1.0" encoding="iso-8859-1"?>
<GALLERY>
<ITEM media="clip1.swf" />
<ITEM media="image01.jpg" />
<ITEM media="clip2.swf" />
<ITEM media="image02.jpg" />
etc....
</GALLERY>