Private Statement - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

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
- The name of the variable or function that you want to specify as private.
name:String
Example
The following example demonstrates how to restrict access to variables or functions by using
the
keyword. Create a new AS file called Alpha.as:
private
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);
}
}
Statements
221

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