No comment. : )
Gordon Smith Adobe Flex SDK Team ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hoff Sent: Friday, August 15, 2008 12:54 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Method variable scoping problem with Flex compiler I can hear Gordon now; "because AS3 adheres to the ECMA standard. Er, I mean, did..." :-) -TH --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "toofah_gm" <[EMAIL PROTECTED]> wrote: > > It seems to me and my co-workers that the Flex compiler is broken when > it comes to local variable scoping within methods. > > For example: > > for (var i:int=0; i<count; i++) > { > // do something > } > > for (var i:int=0; i<count; i++) > { > // do something else > } > > This gives a compiler warning stating that 'i' is already defined. > But in every other language that I have used, this is completely > valid. Yes 'i' was defined above, but 'i' should only be scoped > within the 'for' loop and should be invalid outside of it. > > > > Another example: > > if (x) > { > var myArray:Array = new Array(); > // do more stuff > } > > myArray.push("some data"); > > This one compiles, when I believe that it shouldn't. myArray should > only be defined within the 'if' statement. If you don't go into the > 'if' statement you have a problem here. > > > Does anyone understand why the Flex compiler allows this? Is this > just a BUG with the compiler? > > Anyway, this is just driving me a little crazy. ;) > > Gary >