get
Availability
Flash Player 6.
Usage
function get property() {
// your statements here
}
Parameters
The word you use to refer to the property that
property
same as the value used in the corresponding
Returns
Nothing.
Description
Keyword; permits implicit getting of properties associated with objects based on classes you have
defined in external class files. Using implicit get methods lets you access properties of objects
without accessing the property directly. Implicit get/set methods are syntactic shorthand for the
Object.addProperty()
For more information, see
Example
In the following example, you define a Team class. The Team class includes get/set methods that
let you retrieve and set properties within the class:
class Team {
var teamName:String;
var teamCode:String;
var teamPlayers:Array = new Array();
function Team(param_name:String, param_code:String) {
this.teamName = param_name;
this.teamCode = param_code;
}
function get name():String {
return this.teamName;
}
function set name(param_name:String):Void {
this.teamName = param_name;
}
}
Enter the following ActionScript in a frame on the Timeline:
var giants:Team = new Team("San Fran", "SFO");
trace(giants.name);
giants.name = "San Francisco";
trace(giants.name);
/* output:
ActionScript Core Language Elements
set
method in ActionScript 1.
"Implicit getter/setter methods" on page
accesses; this value must be the
get
command.
63.
CHAPTER 5
get
165
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?