10.
Type the following code into the Actions panel:
var myExample:ConstExample = new ConstExample();
trace(myExample.EXAMPLE_PUBLIC); // output: Public access
This code instantiates the myExample instance and accesses the
property.
11.
Select Control > Test Movie to test your document.
You see
Public access
12.
In the Actions panel, delete the trace statement that you added in step 10.
13.
Type the following code into the Actions panel.
trace(myExample.EXAMPLE_PRIVATE); // error
The
EXAMPLE_PRIVATE
class definition.
14.
Select Control > Test Movie to test your document.
You see
The member is private and cannot be accessed
For more information on built-in classes and creating custom classes, see
"Classes," on page
About keywords
Keywords are words in ActionScript that do one specific thing. For example, you use the
keyword to declare a variable. The
var myAge:Number = 26;
A keyword is a reserved word that has a specific meaning: for example, you use the
keyword to define new a new ActionScript class; and you use the
variables. Other examples of reserved keywords are:
Keywords cannot be used as identifiers (such as variable, function, or label names), and you
should not use them elsewhere in your FLA files for other things (such as instance names).
You have already used the
Data Types," on page
Therefore, you can't use keywords as identifiers (such as variable, function, or label names).
You can find a list of these keywords in
138
Syntax and Language Fundamentals
in the Output panel.
property is a private property, so it is available only within the
225.
keyword is shown in the following line of code:
var
keyword a lot, particularly if you read
var
71. ActionScript reserves words in the language for specific use.
"About reserved words" on page
EXAMPLE_PUBLIC
in the Output panel.
keyword to declare local
var
,
,
,
if
else
this
function
Chapter 4, "Data and
139.
Chapter 7,
var
class
, and
.
return
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?