I am trying to get links onto images loaded into a *MC *in a flash slideshow using XML.
I am not having much success with the accessing of an array created from an XML file.
The main A/S is below, along with the trace of the array pulled from the XML doc. and the XML doc. itself is there also.
Any pointers most greatfully received.
XML file reads:
<slideshow>
<settings>
<image_folder>slides/Images/</image_folder>
<time>2</time>
<fade>2</fade>
<repeat>true</repeat>
<captions>false</captions>
<link> http://www.site.co.uk/</link>
</settings>
<images>
<image>
<file>lotus.jpg</file>
<caption>
<![CDATA[]]>
</caption>
<link>NEWSITE/home.htm</link>
</image>
<image>
<file>zooop_car.jpg</file>
<caption>
<![CDATA[]]>
</caption>
<link>NEWSITE/home.htm</link>
</image>
<image>
<file>lotus.jpg</file>
<caption>
<![CDATA[ ]]>
</caption>
<link>NEWSITE/home.htm</link>
</image>
<image>
<file>solcar.jpg</file>
<caption>
<![CDATA[ ]]>
</caption>
<link>NEWSITE/home.htm</link>
</image>
<image>
<file>CC1.jpg</file>
<caption>
<![CDATA[ ]]>
</caption>
<link>NEWSITE/home.htm</link>
</image>
</images>
</slideshow>
Trace of array from output window reads:
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.site.co.uk/</link></settings>
xm<slideshow><settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.3bdesign.co.uk/</link></settings><images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images></slideshow>
xm<image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images>
xm<image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image>
xm<images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images>
xm<image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images>
xm<image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images>
xm<image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image>
xm<images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images>
xm<slideshow><settings><image_folder>slides/Images/</image_folder><time>2</time><fade>2</fade><repeat>true</repeat><captions>false</captions><link> http://www.3bdesign.co.uk/</link></settings><images><image><file>lotus.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>zooop_car.jpg</file><caption></caption><link>NEWSITE/home.htm</link></image><image><file>lotus.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>solcar.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image><image><file>CC1.jpg</file><caption> </caption><link>NEWSITE/home.htm</link></image></images></slideshow>
Main A/S reads
// Disable slideshow movie scaling
fscommand("allowscale", "false");
// Hide the captions box while images are loading
_root.caption._visible = false;
//base URL
_root.baseURL = "http://www.site.co.uk/"
//var urlArray=new Array();
// Load and parse the slideshow variables
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = parse_data;
xmlData.load("slides/slideshow2.xml");
//urlArray.push(slideshow[1].images[i-1].image[3].nodeValue);
//slideshow[1].images[i-1].image[3].value
// Parameters: success - boolean.
//
// Check to see if the XML data being loaded into the XML object had loaded
// properly. If it has, call parseXmlArray passing it the XML object. Otherwise,
// output an error.
function parse_data(success){
if(success == true){
xmlData = parseXmlToArray(xmlData.firstChild);
//xmlLinks = parseXmlToArray(xmlData.firstChild.childNodes.childNodes[3]);
//urlArray= parseXmlToArray(xmlData.firstChild.childNodes*.childNodes[5].nodeValue);
//trace("urlArray =" + urlArray);
//trace("xmlData =" + xmlData);
//trace(xmlData);
//xml_data.text = "Parse was succsessful. Use debug to view the xmlData variable.";
} //else {
//xml_data.text = "Error:
The XML document did not load properly.
";
//}
}
// Constructor:
// multiNodeObject
//
// Methods:
// - length()
// returns number of numbered items in the object.
// Default Constructor
function multiNodeObject() {}
// Inherits properties from class object
multiNodeObject.prototype = new Object();
// Length method:
// Caculates and returns the number of numbered items in the object
multiNodeObject.prototype.length = function(){
var count = 0;
for(var name in this){
var addCount = true;
for(var i=0; i<name.length; i++){
if(name.charCodeAt(i) < 48 || name.charCodeAt(i) > 57){
addCount = false;
}
}
if(addCount){
count++;
}
}
return count;
};
// Register the Class multiNodeObject
Object.registerClass("multiNodeObject", multiNodeObject);
//parseXmlToAttay
function parseXmlToArray(xm){
// temporary object that will be returned
var temp_obj = new Object();
// see if the current xml object has any children. If it doesn't,
// There is not data here and the function will end.
if(xm.hasChildNodes() && xm.childNodes.length > 1){
temp_obj[xm.nodeName] = new multiNodeObject();
for(var i=0; i<xm.childNodes.length; i++){
temp_obj[xm.nodeName]* = parseXmlToArray(xm.childNodes*);
trace("xm"+xm);
/////////////////////////////////////////////var linkit["value"] = [xm.images.image.link];
}
} else if(xm.hasChildNodes() && xm.childNodes.length == 1){
if(xm.firstChild.nodeType == 1){
temp_obj[xm.nodeName] = parseXmlToArray(xm.firstChild);
} else if(xm.firstChild.nodeType == 3){
var temp2 = new Object();
temp2["value"] = xm.firstChild.nodeValue;
// Outputs the current nodes' attributs array to the xml_data textbox
if(xm.attributes){
for(var name in xm.attributes){
temp2[name] = xm.attributes[name];
xml_data.text = xml_data.text + "-" + name + " : " + xm.attributes[name] + "
";
}
}
temp_obj[xm.nodeName] = temp2;
}
}
// Outputs the current nodes' attributs array to the xml_data textbox
/*if(xm.attributes){
for(var name in xm.attributes){
temp_obj[xm.nodeName][name] = xm.attributes[name];
xml_data.text = xml_data.text + "-" + name + " : " + xm.attributes[name] + "
";
}
}*/
return temp_obj;
}
I keep getting a link to the source folder!?