Maybe impossible XML?

Anyway it soon kills me here in Sweden. And so does the cold weather coming in… :frowning:

Let me first try to explain my layout. I have a index.swf loading all my external swf. That works fine. Then all of my main categories folders are named main1, main2, main3 etc. Inside of the main folders I have image folders containing my images for the different sub sections (image1, image2, image3 etc) and swf’s for each sub sections in my main categories named sub1.swf, sub2.swf, sub3.swf etc which loads images using XML. It’s in these sub.swf’s my problem resides, I think. My problem is how to get my different swf’s to read only the data intended for each sub section. Puh!

I think it has to do with …childNodes.childNodes[1]… and so on which I can’t figure out.

A under construction example of the site can be seen here: http://www.gregory.se/heja.html

What I’m trying to accomplish is to control the loading of images to the different sub sections using only one XML file that looks like this (in short version);

XML file:


<?xml version="1.0" encoding="iso-8859-1" ?>

<xmlData>
	<main>
		<subnumber>
			<subinfo>
				<path>main1/images1/01.jpg</path>
				<info><![CDATA[<p>main1, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main1/images2/01.jpg</path>
				<info><![CDATA[<p>main1, sub2</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main1/images2/02.jpg</path>
				<info><![CDATA[<p>main1, sub2</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
	<main>
		<subnumber>
			<subinfo>
				<path>main2/images1/01.jpg</path>
				<info><![CDATA[<p>main2, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main2/images1/02.jpg</path>
				<info><![CDATA[<p>main2, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main2/images2/01.jpg</path>
				<info><![CDATA[<p>main2, sub2</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
	<main>
		<subnumber>
			<subinfo>
				<path>main3/images1/01.jpg</path>
				<info><![CDATA[<p>main3, sub1</p>]]></info>
			</subinfo>
			<subinfo>
				<path>main3/images1/02.jpg</path>
				<info><![CDATA[<p>main3, sub1</p>]]></info>
			</subinfo>
		</subnumber>
	</main>
<xmlData>

In my sub.swf’s I have this code:


var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild;
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")

I myself tried this, without luck but please anyone tell me if I’m on right track or not…


var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild[0];
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes[0].childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes[0].childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")

Looks like this when working for each sub.swf I have to change the [0] in the second childNode in my xmlData var to whatever node I wish to start on.


var pArray = new Array();
var tArray = new Array();

var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
    if (success) {
        var xmlData = this.firstChild.childNodes[0].childNodes[0];
		for (var i = 0; i<xmlData.childNodes.length; i++) {
			pArray.push(xmlData.childNodes*.childNodes[0].firstChild.nodeValue);
			tArray.push(xmlData.childNodes*.childNodes[1].firstChild.nodeValue);
        }
		containerMC.loadPic(0);
		picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
    } else {
        picInfo.text = "Unable to load external file.";
    }
}
myXML.load("xml/XMLdata.xml")