Hey guys...
I have an XML file I'm parsing out into a Flash movie. The XML contains multiple nodes, and within those nodes are multiple attributes.
So, for example, there is a node called — FirstNode. In that is an attribute — FirstNodeID="1" — and then there is another node, also called — FirstNode which has an attribute of — FirstNodeID="2". Each node also has attributes called — Header — and — Body — and so on.
What I'm wondering is, how do I call out specific things based on an attribute?
Right now, when I call the — Header — attribute from — FirstNode — I get ALL of the Header information from ALL of the FirstNode nodes. I need to be able to get JUST the info from FirstNodeID="1", FirstNodeID="2" and so on as needed.
You can download a sample of my files here.
Here's my current XML code...
Code:
stop();
// LOAD XML
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("demo.xml"));
function LoadXML(e:Event):void {
xmlData=new XML(e.target.data);
ParseHeader(xmlData);
}
//PARSE XML INTO FIELDS
function ParseHeader(headerInput:XML):void {
//MAIN TEXT
var headerList:XMLList=headerInput.ContainerNode.FirstNode.attribute("Heading");
for each (var headerElement:XML in headerList) {
MovieClip(this).text_header.appendText ((headerElement) + "\n");
}
var subtextList:XMLList=headerInput.ContainerNode.FirstNode.attribute("Descr");
for each (var subtextElement:XML in subtextList) {
MovieClip(this).sub_text.appendText ((subtextElement) + "\n");
}
var nexttextList:XMLList=headerInput.ContainerNode.FirstNode.attribute("NextText");
for each (var nexttextElement:XML in nexttextList) {
MovieClip(this).next_text.appendText ((nexttextElement) + "\n");
}
//END
}
My SECOND question is this.
Is there a way to call things from this same XML file in subsequent frames without having to redo all that actionscript?
Right now the only way know to do it is to copy and paste all of that into another frame and rename everything so that it doens't conflict with itself.
In other words I have to take...
Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
And change it to...
Code:
var xmlLoader2:URLLoader = new URLLoader();
var xmlData2:XML = new XML();
and so on...
I'd like to be able to be able to simply rename the dynamic text fields and then only paste in the actionscript that defines what nodes to pull the text from and what fields to put it into. So everything from the //MAIN TEXT area in the actionscript above.
Is this possible?
Am I making myself clear?
Thanks!
http://www.parkeastinc.com/xml_demo_cs3.zip