Helpful Information
 
 
Category: Flash Help
xml and flash

i have a real simple xml doc (quickinfo.xml) with info about buildings in it that looks like this...

<?xml version="1.0"?>
<quickinfo>
<building bname="Alumni House"
description="Fenstemaker Alumni House built in 1967."
instructions="Click left menu or building image." />
</quickinfo>

(more buildings than this)
based on whatever button a user clicks it will load this info into a dynamic text field. however i can't get flash to get to the right part of the tree...this is just test code to see if i could get one of the building names to show up. (i took out the "if (success) {}" part and opted to just throw the value in the output window)

quickinfo = new XML();
quickinfo.onLoad = QIOnLoad;
quickinfo.load("quickinfo.xml");
function QIOnLoad (success) {
trace("Success is " + success);
var buildingListNode = this.firstChild;
trace("Node bname: " + buildingListNode.childNodes[0].attributes.bname);
}

its prolly just a stupid error...as with all of my errors...thanks, rob

i got it...it was a combo problem between flashes problems with whitespace and my problem with book learnin...

so what was the solution? was there actually an error in your actionscript aside from not accounting for whitespace?

TotalMonkey

one part of the problem is that when flash 5 first came out their xml handling was a bit screwy about carriage returns and whitespace...its kinda been fixed since build 30 or sumpin...but it has to be one straight line in order for older flash players to work well...the other issue i had was with flash not being able to handle text node aside from "parent nodes" so instead of having your data in tags like

<id>1234567890</id>

you have to have it in attributes like...

<person id="1234567890"></person>

third problem was my abismal failure of programming...to go deeper into nodes i figured i would just use notation like...

mainnode.firstchild.firstchild and so on...

so by that rational i just wrote...

mainnode.firstchild.attributes.id

but it worked when i changed it to

myArray = new array;
myArray = mainnode.childnodes;
which returns an array of references to the children
then myArray[x].attributes.id to grab the info i wanted...

hopefully that makes sense...rob

my advice, GO HERE (http://chattyfig.figleaf.com/ack/) , it's a prototype function by Branden at Figleaf that not only re writes the ignore whitespace to cover all flash 5 players, but also stops the flash lock up when parsing XML and allows you to show a preload bar of the XML data coming in.

And it's free.










privacy (GDPR)