What is the best practice/coding standard with regard to the ‘this’ scope is AS3? Is there one? I feel it really helps with standardization and my readability, but sometimes it seems like ‘too much’.
For instance, is the use of ‘this’ in the following really necessary (I know it works without ‘this’)?:
private var _item:Object; private var selectedItem:Object; public function set item(value:Object):void { this._item = value; if (this._item['label'] == 'doodad') this.selectedItem = value; } public function set item(value:Object):void { return this._item; }
‘this’ is not required unless you want to prevent naming conflicts between locally scoped variables (method params for instance) and instance variables.
In your example you are already using an underscore to mark a private variable, so it’s an extra reason not to use ‘this’ since you are really saying twice the same thing.