This has been brought up and it's going to be fixed down the road with ECMA.
Search the archives for Gordon's response. You won't be able to use var,
it's some other weird keyword, I can't remember.
Peace, Mike
On 1/11/07, Jason Hawryluk <[EMAIL PROTECTED]> wrote:
kind of like you can't do this
public function clearTargetData(x:string):void{}
public function clearTargetData():void{}
which most support also, but I give Adobe the benefit of the doubt this is
a completely new flex, built from the ground up, and they have done a bang
up job.
I can do with out these things, perhaps they'll implement this type of
stuff in a later version.
jason
-----Message d'origine-----
*De :* [email protected] [mailto:[EMAIL PROTECTED]
la part de* sbyrne_dorado
*Envoyé :* jeudi 11 janvier 2007 10:09
*À :* [email protected]
*Objet :* [flexcoders] Lexical scoping of variable declarations not
working?
I'm seeing some odd behavior with the AS3 compiler. I say it's "odd"
because it's at variance with the vast majority of C language
derivatives (in fact, I'll go out on a limb and say ALL of them). The
behavior I'm seeing is this:
If I have
package {
public class badscope {
public function dummy() : void {
if (new Date() != null) {
var foo : Number = 3;
} else {
var foo : Number = 4;
}
}
}
}
the cmopiler is telling me that "foo" is a duplicate declaration. Um.
Every other block structured language I'm familiar with scopes local
variable declaration to the enclosing block, so the foo's do not exist
in the same lexical scope and there is no conflict. To me, if this
behavior of placing all variable declarations in the top level
function's scope is in fact the desired behavior, it's a HUGE step
backwards.
Please help me to understand why I'm seeing the behavior I am, and why
it's not breaking lexical scoping rules common to C derivatives.
--
Teoti Graphix
http://www.teotigraphix.com
Blog - Flex2Components
http://www.flex2components.com
You can find more by solving the problem then by 'asking the question'.