;

PDA

Click to See Complete Forum and Search --> : [RESOLVED] must be doing something minor and dumb- XML into List component


krashe1313
07-17-2009, 04:04 PM
RESOLVED*

I hope this is simple. Seems like i just have something a hair off.

On my stage, i have the List component with the instance name of "theList".
Along with the following code:
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);

var xml:XML;

function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
var il:XMLList = xml.item;
for (var i:uint =0; i <il.length(); i++)
{
theList.addItem({label:il.item.text()[i]});
trace(il.text()[i]);
}


}

loader.load(new URLRequest("http://localhost:8888/MAMP/SHIELDS/products.php"));

Now products.php, links to a mySql database and those two are playing together just fine. When I run
trace(il.text()[i]);

I get the complete item list that looks exactly like this in the output window:
Beach Ball
LawnChair
Hammock
Electric Razor
Pool Cue
Coffee Machine
Organizer

Perfect.

I just can't get the item list to appear on my list component "theList" on line:

theList.addItem({label:il.item.text()[i]});

All i get is a blank rectangle for each item that i can roll over. No text though.

Thoughts?

Big thanks!!!
`Shields

*In my line:

theList.addItem({label:il.item.text()[i]});

i accidentally put the .item in before the text() and I didn't need to because i declared it earlier at:
var il:XMLList = xml.item;
i knew it was a dumb mistake. thanks for your time