Flex compiler warning - variable 'item' has no type declaration

2.9k Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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); 
}