Flash Pre-built Actions

 < Day Day Up > 



When the Actions panel is open, you can add actions in several different ways. You can open the appropriate book, and double-click the action you want to add (it will be added to the right pane) or you can click and drag the action over to the right pane. You can click the plus sign (+) and choose from that list. After you make a selection, the code is automatically added to the right pane. You can choose Expert mode from the Options pop-up menu and type your own actions or use a combination of pre-built and hand coding.

In the Actions toolbox and in the Actions folder you'll see additional folders for Movie Control, which contains actions such as goto, on, play, stop, stopAllSounds. There are additional folders inside the Actions folder and at the same level as the Actions folder as well, such as Movie Clip Control, Variables, printing, and more. Dividing the actions into specific folders makes it much easier for you to locate the ones you want. In addition to the Actions folder, other categories such as Functions and Properties are available.

Note 

There is a new category of actions in the Actions panel called Deprecated. These are actions that are being phased out.

The best way to see what the actions do is to select an action, and in Normal mode a description will show in the Parameters pane. In Expert mode hold your cursor over the action and a description will appear.

Another way to learn about the various actions is to use the built-in Reference panel. To use it, select an action and then click on the Little book with a question mark on it icon. It's located on the right side of the Actions panel next to the Debug and the View options icons.

Color coding

A new and helpful feature for people trying to learn how to code ActionScript is color coding. The colors can assist you in learning code. Keywords and identifiers are dark blue; comments (which are ignored by Flash) are gray, and anything between quote marks are blue. If you forget to close the quotes, what you typed remains gray until you close it. At times, code hints appear to help you write your syntax. Code coloring is a preference, so if you want to use it choose Edit ® Preferences ® ActionScript Editor tab (Figure 28-2). It's on by default. You can uncheck the option or change the default colors.


Figure 28-2: The ActionScript Editor tab of the Preferences dialog box, where you can change the color-coding colors or toggle it on or off

Tip 

Keywords are case-sensitive. For instance if you type goToAndPlay, the code would not turn blue because it's not accurate. You have to type gotoAndPlay.

Adding an action to a frame

Let's take a look at the goto action in the Movie Control folder of the Actions category. This action is basic and easy to use and understand.

ActionScript is written into the Flash Action window in the Actions panel either by using menus (on the left) or by choosing Expert mode (Options pop-up menu) and typing your own syntax. ActionScript is added to frames, buttons, or objects.

To add ActionScript to a frame, follow these steps:

  1. With a new movie open, draw a simple rectangle on the stage and select the frame to receive the ActionScript.

  2. Open the Actions panel.

  3. In Normal mode, click the Actions book to open it; then click the Movie Control to open it. Double-click goto. Double-clicking adds the syntax to the right pane. You can also drag the action into the right pane (white area). An alternative way of selecting the action is to click the plus (+) sign and choose from the menu there; the syntax is automatically added to the right pane. Figure 28-3 is how it looks in Normal mode.

    click to expand
    Figure 28-3: The Actions panel in Normal mode showing the goto action added

    Note 

    You add code below any existing code in Normal mode by clicking the existing statement to highlight it then double-clicking an action from the actions list to add the code. You can drag code to rearrange or even copy and paste it.

  4. Switch to Expert mode. Figure 28-4 shows what the same code looks like in Expert mode.

    click to expand
    Figure 28-4: The Actions panel in Expert mode showing the goto action added

This statement says to go to and play a specified frame, which is indicated by a number in the parenthesis. The other variation of the goto action is gotoAndStop, which goes to a specified frame and stops. These actions are frequently used with buttons.

Actions that contain parameters that you need to specify have the parameter choices in the parameters area above the script window. For instance, the goto action has parameters but the play action doesn't.

The parameters for goto are

  • Scene — You can choose various scenes.

  • Type — You choose the frame number, frame label, expression, next frame, or previous frame to be the target of the action. The choices are self-explanatory except for Expression. Expressions are used to assign targets of goto actions dynamically.

  • Frame — This area varies depending on which Type you select. If you choose Frame, you enter the frame number here. If you choose Frame Label, you enter the label name.

  • Go to And Play or Go to And Stop.

Note 

You can edit code in Expert mode by selecting any portion of a statement and edit it. But be sure to check your syntax for accuracy.

A practical use for the goto action is a simple preloader. A preloader indicates that a movie is loading and how much time is left. This is useful if your movie takes more than a few seconds to open. Often a preloader contains something (audio, video) to entertain the user while he or she waits for the movie to load.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net