PDA

View Full Version : for..in loop and Flex warning


darth
11-11-2008, 12:55 PM
So in Flex I have actionscript project and this line

for(var i in LoaderInfo(this.root.loaderInfo).parameters){

gives me

1008: variable 'i' has no type declaration.

warning.

How do I get rid of it?

fnx
11-11-2008, 01:31 PM
If you know what type are the .parametes (eg:Object but you can see it by using the
flex debugger) you just have to write:

for (var i:Object in...

else if you don't know or not sure about the type, just write

for (var i:* in...

that is a "variant" declaration (the type is undefined until the var get the value of the
object)

In flex every variable must by typed :)

darth
11-11-2008, 01:36 PM
Thanks!
However String type should be enough for flashvars.

fnx
11-11-2008, 01:46 PM
Sure, I was not saying that about flashvars but as a general approach ;)

darth
11-11-2008, 01:50 PM
Oh yes that's what I really wanted to know :p how to use it in general ;)