There is no right answer ;-)
When the first Flash component framework was released, private variables had a
double underscore.
__width
__height
etc..
Basically because they usually replaced existing built-in properties, like
_width, _height, etc..
So what we ended up with was:
Built-in
_width
_height
Private
__width
__heigth
Public
width
height
Personally, I wouldn't use single underscores, because built-in properties use
them (in AS1 and AS2).
A component that needs its own sizing capabilities would then look something
like this:
class MyComponent extends MovieClip {
private var __width:Number;
private var __height:Number;
function MyComponent() {
__width = _width;
__height = _height;
// remove scaling that occured on stage
_xscale = _yscale = 100;
}
private funcion size():Void {
//use __width and __height for sizing..
}
public function setSize(w:Number, h:Number):Void {
__width = w;
__height = h;
size();
}
public function get width():Number {
return __width;
}
public function get height():Number {
return __height;
}
}
Might be some errors in the above code as I quickly wrote it down.
regards,
Muzak
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, June 02, 2007 12:25 AM
Subject: [Flashcoders] Best Practices question...
> Hi all,
>
> this should be kind of a simple one. I have been creating my Private
> variables as simple camelCased names.
>
> private var variableName:VariableType;
>
> I have seen other people creating them as underscore camelCased names and
> recently I was challenged that the underscore was the correct and best
> practice.
>
> private var _variableName:VariableType;
>
> I'm not convinced. Does any one have any definative information or
> experience of this from an OO best practices perspective and an
> explanation of why the right answer is right?
>
> Thanks all
>
> S.
_______________________________________________
[email protected]
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