views:

724

answers:

1

I am tyring to learn flex programming myself. Below code gives me a warning

variable 'item' has no type declaration.

var xml:XML = xml as XML;

for each (var item in xml.employee) {
    Alert.show(item.@name); 
}

What is the type of variable item? I thought it was XMLNode, but it give me error. I want to remove the compile warning.

+1  A: 

Use this please, you haven't initialized item.


var xml:XML = new XML();

for each (var item:XML in xml.employee) {
    Alert.show(item.@name); 
}
nicko
It works. So, item is of type XML. Thanks.