62 Chapter 3: Writing and Debugging Scripts
Strictly typing objects to trigger code hints
When you use ActionScript 2.0, you can strictly type a variable that is based on a built-in class,
such as Button, Array, and so on. If you do so, the ActionScript editor displays code hints for the
variable. For example, suppose you type the following:
var names:Array = new Array();
names.
As soon as you type the period (.), Flash displays a list of methods and properties available for
Array objects, because you have typed the variable as an array. For more information on data
typing, see “Strict data typing” on page 38. For information on using code hints when they
appear, see “Using code hints” on page 63.
Using suffixes to trigger code hints
If you use ActionScript 1 or you want to display code hints for objects you create without strictly
typing them (see “Strictly typing objects to trigger code hints” on page 62), you must add a
special suffix to the name of each object when you create it. For example, the suffixes that trigger
code hinting for the Array class and the Camera class are
_array and _cam, respectively. If you
type the following code:
var my_array = new Array();
var my_cam = Camera.get();
and then type either of the following (the variable name followed by a period), code hints for the
Array and Camera object, respectively, appear.
my_array.
my_cam.
For objects that appear on the Stage, use the suffix in the Instance Name text box in the Property
inspector. For example, to display code hints for MovieClip objects, use the Property inspector to
assign instance names with the suffix
_mc to all MovieClip objects. Then, whenever you type the
instance name followed by a period, code hints appear.
Although suffixes are not required for triggering code hints when you strictly type an object, using
them consistently helps you and others understand your scripts.
The following table lists the suffixes required for support of automatic code hinting:
Object type Variable suffix
Array _array
Button _btn
Camera _cam
Color _color
ContextMenu _cm
ContextMenuItem _cmi
Date _date
Error _err
LoadVars _lv