views:

80

answers:

2

I have this actionscript so far:

var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("nav.xml"));

function LoadXML(e:Event):void {

xmlData = new XML(e.target.data); ParseBooks(xmlData);

}

function ParseBooks(bookInput:XML):void {

trace("XML Output"); trace("------------------------"); trace(bookInput); trace(bookInput.project);

}

This loads the xml, assigns it to bookInput and traces it, but when I try and trace bookInput.project, or bookInput.button, or anything besides bookInput, no data is returned, does anyone know why this is?

XML;

    <button label="test1">

        <project path="http://www.google.com"&gt;


        </project>

    </button>

    <button label="test2">

        <project path="projects/drawing/DrawingApp.swf">

        </project>

    </button>

    <button label="test3">

        <project path="projects/text/DrawingApp.swf">

        </project>

    </button>

 </buttons>

A: 

my bad, forgot to make it bookInput.buttons.button

A: 
<project path="projects/text/DrawingApp.swf">
</project>

is the same as

<project path="projects/text/DrawingApp.swf" />

it's an empty node...well sort of. It's text node is empty, there is no node value. In as3, if you trace a node that has no children it assume you want an XML not an XMLList, so it traces the node value. try to trace project.@path instead of just project.

bookInput.project is not the right path bookInput is buttons bookInput.button is an XMLList of all your button nodes, and so on.

so if you want to get to the first node you can try

bookInput.button[0].project.@path;

either have a look at the xml chapter in essential actionscript 3.0, or you can easily scan this great article to get started.

Sorry I'm writting this in a hurry, hope I make sense.

George Profenza