138
Syntax and Language Fundamentals
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
EXAMPLE_PUBLIC
property.
11.
Select Control > Test Movie to test your document.
You see
Public access
in the Output panel.
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
property is a private property, so it is available only within the
class definition.
14.
Select Control > Test Movie to test your document.
You see
The member is private and cannot be accessed
in the Output panel.
For more information on built-in classes and creating custom classes, see
Chapter 7,
“Classes,” on page 225
.
About keywords
Keywords are words in ActionScript that do one specific thing. For example, you use the
var
keyword to declare a variable. The
var
keyword is shown in the following line of code:
var myAge:Number = 26;
A keyword is a reserved word that has a specific meaning: for example, you use the
class
keyword to define new a new ActionScript class; and you use the
var
keyword to declare local
variables. Other examples of reserved keywords are:
if
,
else
,
this
,
function
, and
return
.
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
var
keyword a lot, particularly if you read
Chapter 4, “Data and
Data Types,” on page 71
. ActionScript reserves words in the language for specific use.
Therefore, you can’t use keywords as identifiers (such as variable, function, or label names).
You can find a list of these keywords in
“About reserved words” on page 139
.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...