private
Availability
Flash Player 6.
Usage
class someClassName{
private var name;
private function name() {
// your statements here
}
}
Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash
tab of your FLA file's Publish Settings dialog box. This keyword is supported only when used in
external script files, not in scripts written in the Actions panel.
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" in Using ActionScript in Flash.
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. Enter the following
ActionScript in Frame 1 of the Timeline.
ActionScript Language Reference
CHAPTER 2
private
707
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?