Set Statement - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

See also
function statement

set statement

function set property(varName) {
// your statements here
}
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 object's
property without accessing the property directly. Implicit get/set methods are syntactic
shorthand for the
Object.addProperty()
Availability: ActionScript 2.0; Flash Player 6
Parameters
- Word that refers to the property that
property:String
the same as the value used in the corresponding
Example
The following example creates a Login class that demonstrates how the
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;
}
}
In a FLA or AS file that is in the same directory as Login.as, enter the following ActionScript
in Frame 1 of the Timeline:
var gus:Login = new Login("Gus", "Smith");
trace(gus.username); // output: Gus
224
ActionScript language elements
method in ActionScript 1.0.
will access; this value must be
set
command.
get
keyword can be
set

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF