User Guide

set 199
set
Availability
Flash Player 6.
Usage
function set property(varName) {
// your statements here
}
Parameters
property
Word that refers to the property that set will access; this value must be the same as
the value used in the corresponding
get command.
varName The local variable that sets the value youre assigning.
Returns
Nothing.
Description
Keyword; permits implicit setting of properties associated with objects based on classes you have
defined in external class files. Using implicit set methods lets you modify the value of an objects
property without accessing the property directly. Implicit get/set methods are syntactic shorthand
for the
Object.addProperty() method in ActionScript 1. For more information, see “Implicit
getter/setter methods” on page 63.
Example
The following example creates a Login class that demonstrates how the set keyword can be used
to set private variables:
class Login {
private var loginUserName:String;
private var loginPassword:String;
public function Login(param_username:String, param_password:String) {
this.loginUserName = param_username;
this.loginPassword = param_password;
}
public function get username():String {
return this.loginUserName;
}
public function set username(param_username:String):Void {
this.loginUserName = param_username;
}
public function set password(param_password:String):Void {
this.loginPassword = param_password;
}
}
CHAPTER 5
ActionScript Core Language Elements