PDA

View Full Version : DataProvider


RickyNilsson
11-13-2007, 05:01 PM
Have a little problem with List and DataProvider.

Ok, so I have an inventory that add different items.
invlist.addItem({label:"key"});
All that work fine and you can see "key" in the List.

But later on I need to check if I have the key in my inventory.

Was thinking something like:
if(invlist.label == "key"){ .............

Though that doesn't work...
Anyone done something in this and know how to use it?

ryryguy
11-13-2007, 05:52 PM
You can iterate over the items in the data provider kinda like it was an array:


var haskey:Boolean = false;
for( var index:uint = 0; index < invlist.length; index++ )
{
if( invlist.getItemAt(index).label == "key" )
{
haskey = true;
break;
}
}

if( haskey )
{ //...
}