When you work in the ActionScript editor (either in the Actions panel or Script window), Flash can detect what action you are entering and display a code hint--a tooltip that contains the complete syntax for that action or a pop-up menu that lists possible method or property names. Code hints appear for parameters, properties, and events when you strictly type or name your objects, as discussed in the rest of this section. Code hints also appear if you double-click an item in the Actions toolbox or the Add (+) button above the Script pane to add actions to the Script pane. For information on using code hints when they appear, see Using code hints.
Note: Code hinting is enabled automatically for native classes that don't require you to create and name an instance of the class, such as Math, Key, Mouse, and so on.
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 code:
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. For information on using code hints when they appear, see Using 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), 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. For example, if you type the following code:
var my_array = new Array(); var my_cam = Camera.get();
Then you can type either of the following (the variable name followed by a period):
my_array. my_cam.
You will see code hints for the Array and Camera object, respectively, appear.
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 make your code understandable.
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 |
|
LocalConnection |
_lc |
|
Microphone |
_mic |
|
MovieClip |
_mc |
|
MovieClipLoader |
_mcl |
|
PrintJob |
_pj |
|
NetConnection |
_nc |
|
NetStream |
_ns |
|
SharedObject |
_so |
|
Sound |
_sound |
|
String |
_str |
|
TextField |
_txt |
|
TextFormat |
_fmt |
|
Video |
_video |
|
XML |
_xml |
|
XMLNode |
_xmlnode |
|
XMLSocket |
_xmlsocket |
For information on using code hints when they appear, see Using code hints.
You can also use ActionScript comments to specify an object's class for code hinting. The following example tells ActionScript that the class of the instance theObject is Object, and so on. If you were to enter mc followed by a period after these comments, a code hint would display the list of MovieClip methods and properties; if you were to enter theArray followed by a period, a code hint would display a list of Array methods and properties; and so on.
// Object theObject; // Array theArray; // MovieClip mc;
However, Macromedia recommends that, instead of this technique, you use strict data typing (see Strictly typing objects to trigger code hints) or suffixes (see Using suffixes to trigger code hints) because these techniques enable code hinting automatically and make your code more understandable. For information on using code hints when they appear, see Using code hints.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00000924.html
Comments
javaStephen said on Dec 3, 2004 at 11:18 AM :