MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 195

Actionscript language reference
Table of Contents

Advertisement

private
Availability
Flash Player 6.
Usage
class someClassName{
private var name;
private function name() {
// your statements here
}
}
Parameters
The name of the variable or function that you want to specify as private.
name
Description
Keyword; specifies that a variable or function is available only to the class that declares or defines
it or to subclasses of that class. By default, a variable or function is available to any caller. Use this
keyword if you want to restrict access to a variable or function. For more information, see
"Controlling member access" on page
You can use this keyword only in class definitions, not in interface definitions.
Example
The following example demonstrates how you can hide certain properties within a class using the
keyword. Create a new AS file called Login.as.
private
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 the same directory as Login.as, create a new FLA or AS document.
var gus:Login = new Login("Gus", "Smith");
trace(gus.username); // output: Gus
trace(gus.password); // output: undefined
trace(gus.loginPassword); // error
ActionScript Core Language Elements
53.
CHAPTER 5
import Login:
private
195

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents