We tend to use them to specify private properties.

class MyClass
{
 private var _something1:Number;
 public var something2:Number;
}

Partly because it then makes replacing a public property with a
getter/setter pair easy:
class MyClass
{
 private var _something1:Number;
 private var _something2:Number;
 public function get something2():Number {return _something2;}
 public function set something2(num:Number):Void {_something2=num;}
}

and partly because it's easier to think up names in situations like:

class MyClass
{
 private var _something1:Number;

 public function MyClass(something1:Number)
 {
   _something1=something1;
 }
}

It's a just a convention we use in-house; there aren't any
Actionscript Community wide hard-and-fast rules about it.

Of course, Macromedia themselves vary whether they use underscores or
not for public variables, and I've never figured out the rhyme and
reason. Why _x and _y and _visible but not _enabled? Why not just x
and y?

Cheers,
 Ian


On 8/10/06, Adrian Park <[EMAIL PROTECTED]> wrote:
I've googled for some enlightenment on this but haven't really found many
answers...

I've noticed many class authors prefix property names with an underscore, or
2 underscores or none at all. I often see all three of these prefix 'styles'
in one class. I haven't been able to figure out what the convention is.

Please show me the light.

Thanks
A.
_______________________________________________
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