Writing Scripts with ActionScript > Using code hints

 

Using code hints

When you work in the Actions panel, Flash can detect what action you are entering and display a code hint—a tooltip containing the complete syntax for that action or a pop-up menu listing possible method or property names. In expert mode, code hints appear for parameters, properties, and events when you enter certain characters in the Script pane. In normal mode, code hints appear for parameters and properties (but not events) in the parameter text boxes when the Expression box is selected.

Code hints are enabled by default. By setting preferences, you can disable code hints or determine how quickly they appear. (See Setting Actions panel preferences.) When code hints are disabled in preferences, you can turn them on manually.

 
To enable automatic code hints:

1

Choose Preferences from the Actions panel pop-up menu (at the upper right of the panel).

2

On the ActionScript Editor tab, select Code Hints.

 
To enable manual code hints in expert mode, do one of the following:

Click the Show Code Hint button above the Script pane (at the right side of the Actions panel).

From the Actions panel pop-up menu (at the upper right of the panel), choose Show Code Hints.

Press Control+Spacebar (Windows) or Command+Spacebar (Macintosh).

 
To work with tooltip-style code hints:

1

Type an open parenthesis [(] after an action name.

The code hint appears.

2

Enter a value for the parameter. If there is more than one parameter, separate the values with commas.

3

To dismiss the code hint, do one of the following:

Type a closing parenthesis [)].

Click outside the statement.

Press Escape.

 
To work with menu-style code hints:

1

Display the code hint by doing one of the following:

Type a dot after the suffix of an object name.

Type an open parenthesis [(] after an event handler name.

2

To navigate through the code hint, use the Up and Down Arrow keys.

3

To select an item in the menu, press Return or Tab, or double-click the item.

4

To dismiss the code hint, do one of the following:

Choose one of the menu items.

Click outside the statement.

Type a closing parenthesis [)] if you've already typed an open parenthesis.

Press Escape.

Many ActionScript objects require you to create a new instance of the object in order to use its methods and properties. For example, in the code myMovieClip.gotoAndPlay(3), the gotoAndPlay method tells the instance myMovieClip to go to a specific frame and begin playing the movie clip. The Actions panel doesn't know that the instance myMovieClip is of the object class MovieClip, and therefore doesn't know which code hints to display.

If you want the Actions panel to display code hints for object instances, you must add a special class suffix to each instance name. For example, to display code hints for the class MovieClip, you must name all MovieClip objects with the suffix _mc, as in the following examples:

Circle_mc.gotoAndPlay(1);
Sqaure_mc.stop();
Block_mc.duplicateMovieClip("NewBlock_mc", 100);

The following table shows the suffixes and their corresponding object classes:

Suffix

Object class

_mc

MovieClip

_array

Array

_str

String

_btn

Button

_txt

TextField

_fmt

TextFormat

_date

Date

_sound

Sound

_xml

XML

_xmlsocket

XMLSocket

_color

Color

_camera

Camera

_mic

Microphone

_stream

NetStream

_connection

NetConnection

_so

SharedObject

_video

Video


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 the code mc after these comments, a code hint would display the list of MovieClip methods and properties; if you were to enter the code theArray, a code hint would display a list of Array methods and properties.

// Object theObject;
// Array theArray;
// MovieClip mc;

For more information about object classes in ActionScript, see About object-oriented scripting.