What is the deal with the dollar sign in this tutorial found at mm?
3D classes tutorial
What is the purpose of the dollar sign?
Here is a sample of the code:
[AS]class com.lo9ic.Style {
private var $linealpha, $lineweight, $fillalpha : Number;
private var $linecolor, $fillcolor : String;
function Style() {
$lineweight = 0;
$linealpha = 100; $fillalpha = 100;
$linecolor = “0x000000”; $fillcolor = “0x000000”;
}
public function set linealpha(a:Number):Void {
$linealpha = a;
}[/AS]
system
November 7, 2003, 11:56pm
2
None, really. It’s simply a valid character that you can use to name your objects/functions/properties/etc; like a, b, c, and d.
system
November 8, 2003, 3:03am
3
Thats what I figured, but I tried replicating these classes with out using the $ and am getting some compile errors…
I guess I am overlooking something.
system
November 8, 2003, 3:23am
4
… What’s the error you get? :-\
system
November 8, 2003, 4:50am
5
Ugh…
I dont have MX 2004 at home so I wont be able to tell you till monday afternoon.
Thanks for the help though!
system
November 8, 2003, 4:55am
6
Ok! And now I get to wait.
system
November 8, 2003, 6:58am
8
Ok. So let me make sure I understand this.
The $ is used for private variables.
So do all private vars have to start with $?
The reason I ask is because when I take the $ away from all the private vars, the compiler doesnt like it.
Note: I am only implementing the implicit get/set functions in my classes right now.
Thanks for the help.
system
November 8, 2003, 7:02am
9
the $ is optional, and in fact, leading a variable name by a dollar sign doesn’t make it private. It’s just to indicate that this variables was declared Private
What erros does the compiler throw?
system
November 8, 2003, 7:03am
10
public function set linealpha(a:Number):Void
that line is causing the error cause when your delete the $ signs linealpha has it’s type messed with and flash gives an error.
If you change the $linealpha to something like linealpha1 it should work fine
Anyway good luck,
Shawn
system
November 8, 2003, 7:20am
11
Haha! How on earth could I miss that!?
system
November 8, 2003, 8:04am
12
The forest through the trees…I hate those little things that cause big problems,
Shawn
system
November 8, 2003, 8:08am
13
Yeah, me too. It’s really annoying sometimes. :hair: