I saw this code recently,
public function CursorManager($target:InteractiveObject, $cursor:String) {
_target=$target;
_cursor=$cursor;
_target.addEventListener(MouseEvent.ROLL_OVER, onOver);
_target.addEventListener(MouseEvent.ROLL_OUT, onOut);
}
Why is this person using the $ in the parameter $target? Does it hold any significant meaning? I've seen this in JavaScript as well.
UPDATE:
Is it possible it was used to denote static or constant variable? It does not appear to be used as static in this example.
UPDATE 2:
I found some code in the Flex UIComponent class that uses $width, $height. I've added an answer.
In this example I would say author uses $ prefix to identify variable that comes from outside (function parameter) and prefix _ to identify variable that belongs to the this function or entire class.
So the answer is NO, it doesn't hold any significant meaning. It is done for convenience only . You may want to look into code naming conventions to learn more about that.
When I code JavaScript I use this notation for jQuery-Objects like this:
var $target = $(event.target);
$target.hide();
Others may use this differently.
As Max stated, "the answer is NO, it doesn't hold any significant meaning. It is done for convenience only." but I want to add more. It is not treated any differently by the compiler (as far as I know) but in Flex it is used to signify a base property, it's final and cannot be overridden that is a reflection of a native player implementation.
For example, in the property $scaleX it states:
/**
* This property allows access to the Player's native implementation
* of the <code>scaleX</code> property, which can be useful since components
* can override <code>scaleX</code> and thereby hide the native implementation.
* Note that this "base property" is final and cannot be overridden,
* so you can count on it to reflect what is happening at the player level.
*/
The $width property is the same:
/**
* @private
* This property allows access to the Player's native implementation
* of the 'width' property, which can be useful since components
* can override 'width' and thereby hide the native implementation.
* Note that this "base property" is final and cannot be overridden,
* so you can count on it to reflect what is happening at the player level.
*/
mx_internal final function get $width():Number
{
return super.width; // UIComponent extends FlexSprite which extends Sprite
}
All of the properties that begin with $ in the UIComponent class reflect these attributes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.