Statements
221
trace(myCircle.radius);
trace(myCircle.getArea());
trace(myCircle.getDiameter());
See also
class statement
private statement
class
someClassName
{
private var
name
;
private function
name
() {
// your statements here
}
}
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. This keyword is intended as a
software development aid to facilitate good coding practices such as encapsulation, and not as
a security mechanism to obfuscate or secure sensitive data. It does not necessarily prevent
access to a variable at runtime.
You can use this keyword only in class definitions, not in interface definitions.
Availability:
ActionScript 2.0; Flash Player 6
Parameters
name
:String
- The name of the variable or function that you want to specify as private.
Example
The following example demonstrates how to restrict access to variables or functions by using
the
private
keyword. Create a new AS file called Alpha.as:
class Alpha {
private var privateProperty = "visible only within class and subclasses";
public var publicProperty = "visible everywhere";
}
In the same directory as Alpha.as, create a new AS file named Beta.as that contains the
following code:
class Beta extends Alpha {
function Beta() {
trace("privateProperty is " + privateProperty);
}
}
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...