Correct me if I'm wrong, but it looks like your rationale is entirely
based on an argument name being identical to a class variable name.  I
might be looking at this too simply, but shouldn't you just use a
different argument name if it clashes with a class variable name?

-Steven


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of JOR
> Sent: Tuesday, October 10, 2006 1:19 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Moving to AS2, array always undefined
> 
> Actually, the "need" is dependent on the implementation.
> 
> It was my understanding that AS first looks to the local scope for the
> existence of a variable then works up to find it.  By using "this" you
> were explicitly telling flash that the var isn't local to the function
> but rather belongs to the object cutting out a step for the VM.
> 
> Therefore, something like the following becomes possible and the use
of
> "this" becomes necessary:
> 
> class MyConstructor {
>    private var target:MovieClip;
>    public function MyConstructor (target:MovieClip) {
>      this.target = target;
>    }
> }
> 
> Because you can not do this:
> 
> class MyConstructor {
>    private var target:MovieClip;
>    public function MyConstructor (target:MovieClip) {
>      target = target; // ?
>    }
> }
> 
> However, depending on your naming conventions you "might" not have to
> use "this" if you did something like the following:
> 
> class MyConstructor {
>    private var _target:MovieClip;
>    public function MyConstructor (target:MovieClip) {
>      _target = target;
>    }
> }
> 
> Even still, I think the VM might check for the existence of a var
named
> _target local to the constructor function before locating the object's
> field named _target.
> 
> It's been a while since I've done anything in AS1 so I may be way off
> here but I thought I remembered "this" being necessary because at
weird
> times the VM would think you were trying to instantiate a local var if
> you didn't use "this".  Particularly in "on (something)" event
handlers.
> Maybe I'm thinking of _global, or perhaps both.  This, I'm not sure
> about... if you'll excuse the pun. :)

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to