Macromedia Flash 8 Bible Free Open Book

Macromedia Flash 8 Bible

Previous Page
Next Page

Customizing the Actions Panel

The Actions panel in Flash 8 (and the Script editor in Flash Professional 8) is the primary place for adding interactivity to your movies, which you do by writing your own ActionScript code.

Note 

Whenever you open or create an ActionScript file (.as) in Flash Professional 8, you are using the Script editor to type your code. You do not use the Actions panel whenever you edit an .as file in Flash Professional 8.

Code Hints

If you have code hints enabled when you are typing ActionScript, a pop-up window appears containing relevant syntax, method, and event completion tips. This very useful tool is helpful when you are writing ActionScript because it reveals the suggested syntax of the function or method. Flash 8's code hints, however, work best when it knows what class of object you are addressing. For example, if you name your Movie Clip instance with an _mc suffix, the Actions panel knows that the object is a MovieClip object. When writing code, the most relevant action out of several suggestions is highlighted in the code hints pop-up menu, as shown in Figure 32-1.

Image from book
Figure 32-1: The Code Hints menu

If you press the Enter key at this time, the method or function is completed for you. The cursor is then positioned at the end of the line and a tooltip pops up, providing the necessary parameters for the function or method you are typing. As you type your code, the tooltip makes the parameter you are writing bold. Refer to Figure 32-2 for an example of the Code Hints tooltip.

Image from book
Figure 32-2: The Code Hints tooltip indicates the correct parameters for the attachMovie() method.

If you use ActionScript 2.0's strict typing for variable declarations, you can forego the use of suffixes for your instance names. Flash 8 can automatically show you the code hints for a class of objects if you declare the object's type. For example, if you type the following code into the Actions panel, Flash 8 knows that mcHolder is a MovieClip object:

var mcHolder:MovieClip = createEmptyMovieClip("mcHolder", 1);
Tip 

If you're following along and typing this code into the Actions panel, notice that the Code Hints menu appears after you type the colon (:) following the mcHolder term. This hint menu displays most of the class names available in ActionScript.

Then, if you refer to mcHolder later in your code (as shown in Figure 32-3), the code hints for the MovieClip class appear.

Image from book
Figure 32-3: Code hints work for ActionScript 2.0 declared objects as well.

Code hints remove a lot of the guesswork from writing ActionScript. Using this feature is often faster than traversing the massive list of nodes in the Actions toolbox. There are a few settings you can modify to customize the way code hints work and act.

We'll walk you through the options to customize code hints:

  1. Choose Edit Preferences (Windows) or Flash Preferences (Mac OS X).

  2. Select the ActionScript category. We will focus on the Editing options section.

    Tip 

    You can also access this tab in the Preferences dialog box by selecting Preferences from the Actions panel options menu.

  3. The Automatic indentation check box should already be selected. When you type code into the Script pane, this option controls how your code indents. Adjust the Tab size value to increase or decrease the spacing of the indentation.

  4. Make sure the Code hints check box is selected in order to enable them. We recommend keeping the Delay slider at a value of 0 seconds, which makes the code hints appear automatically as you type. Refer to Figure 32-4 to see how the ActionScript Editor tab should appear.

Image from book
Figure 32-4: The default settings for the Actions panel

If you prefer not to have Code Hints on all the time, you can invoke a code hint whenever needed. While typing your code in the Script pane, do one of the following:

  • Click the Show Code Hint button in the Action panel's toolbar.

  • Select Show Code Hint from the Actions panel options menu.

  • Press Ctrl+spacebar (Windows) or Control+spacebar (Mac).

Syntax Coloring

A feature that was added in the original release of Flash MX was the capability to choose how your ActionScript is colored. Flash 8 has this feature as well. This is known as syntax coloring, and it helps to visually "divide" your ActionScript. There are many elements to ActionScript such as variables, functions, constants, and statements. Using syntax coloring makes it much easier to read ActionScript. Set up your Syntax color settings so that they are easy to read, but also follow common "standards" in syntax highlighting.

  1. Create a new Flash document by choosing File New.

  2. Select the first frame of Layer 1 and open the Actions panel by choosing Window Actions (F9 or Option+F9 on Mac).

  3. Enter the code shown in Listing 32-1 into the Actions panel. This code can be used for testing and modifying syntax coloring because it uses most of the different elements of ActionScript.

    Listing 32-1: Sample Code to Aid Syntax Color Settings

    Image from book

    #include "externalActions.as"
    
    // This is a one line comment.
    
    /*
    
    This is a multiple line comment.
    */
    
    var nIdx:Number = 30;
    var sText:String = "Flash Video";
    
    if (nIdx != 4) {
       var snd:Sound = new Sound(this.mcTarget);
       snd.loadSound("soundFile.mp3");
    } else {
       mcCircle._alpha = this.mcTarget._alpha;
    }
    
    Image from book

  4. Open the Preferences dialog box (to the ActionScript tab) by selecting Preferences from the Actions panel options menu. See Figure 32-5.

  5. Refer to the Syntax colors section in the ActionScript category. You can turn syntax coloring on or off by selecting or clearing the check box next to Syntax colors, respectively.

  6. Select the Foreground color chip and choose black (#000000) from the pop-up swatch menu. The Foreground option sets the default color of the text in the Actions panel. (Unless you changed this setting earlier, the default value should already be black.)

  7. Select the Keywords color chip and choose blue (#0000FF) from the pop-up swatch menu. This blue color highlights all keywords such as var, if, and else.

  8. Select the Identifiers color chip and choose a medium green (#009900). This color is used to highlight terms that are methods and properties of classes, as well as class names themselves.

  9. Set the Background color chip to white (#FFFFFF). You should use white because it is likely you will spend hours at a time typing ActionScript, and black text on a white background has high contrast and is more forgiving on your eyes than a colored background might be. (Unless you changed this setting earlier, the default value should already be white.)

  10. Set the Comments color chip to a bright orange (#FF9900). Most programming applications use a gray for the comment color. We have chosen an orange as we believe that commenting code is a very important (and often neglected) part of authoring (and learning) code. Using a more visible color helps comments stand out more easily from the rest of the code.

  11. Finally, select red (#FF0000) in the Strings color chip. Red is a common color for strings in many programming packages that have syntax coloring.

  12. Click OK to close the Preferences dialog box. Make sure you have the Actions panel open and frame 1 of Layer 1 selected so that you can see the colors in use.

Image from book
Figure 32-5: Accessing the Preferences from the Actions panel

You can modify these colors if you prefer something different — the point of these steps is to illustrate where you can change the colors of your ActionScript code and visibly see those changes on the test code we provide.


Previous Page
Next Page
Index: [A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y][Z]


     Main Menu
Table of Contents
Back Cover
Macromedia Flash 8 Bible
Foreword
Preface
Part I: An Introduction to Flash Web Production
Part II: Mastering the Flash Environment
Part III: Creating Animation and Effects
Part IV: Integrating Media Files with Flash
Part V: Adding Basic Interactivity to Flash Movies
Part VI: Distributing Flash Movies
Part VII: Approaching ActionScript
Part VIII: Applying ActionScript
Chapter 28: Sharing and Loading Assets
Chapter 29: Sending Data In and Out of Flash
Chapter 30: Applying HTML and Text Field Formatting
Chapter 31: Creating a Game in Flash
Chapter 32: Managing and Troubleshooting Flash Movies
Customizing the Actions Panel
Managing Your Code
Using the Output Panel
Knowing the Flash Debugger Panel
Assigning Breakpoints
Debugging a Flash Movie Remotely
Storing Code in External Files
Troubleshooting Guidelines
Community Help
Summary
Part IX: Integrating Components and Data-Binding
Part X: Expanding Flash
Part XI: Appendixes
Index
List of Figures
List of Tables
List of Listings
List of Sidebars


More Books
PHP Hacks
Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
The Koran (Holy Qur'an)
Macromedia Flash 8 Bible
Search Engine Optimization for Dummies
YouTube Traffic
PHP 5 for Dummies
Harry Potter and The Chamber of Secrets
Harry Potter and the Sorcerer's Stone
The Pilgrim's Progress
Wireless Hacks
Flash Hacks. 100 Industrial-Strength Tips & Tools
PayPal Hacks. 100 Industrial-Strength Tips and Tools
Amazon Hacks
Pdf Hacks
The Da Vinci Code
Google Hacks
The Holy Bible
Windows XP For Dummies
Harry Potter and the Half-Blood Prince
Seo Book
Upgrading and Repairing Networks
Macromedia Dreamweaver 8 UNLEASHED
Windows XP Annoyances
Windows XP Hacks
Microsoft Windows XP Power Toolkit
Teach Yourself MS Office In 24Hours
iPod & iTunes Missing Manual
PC Hacks 100 Industrial-Strength Tips and Tools
PC Overclocking, Optimization, and Tuning - 2th Edition
PC Hardware In A Nutshell 3rd Edition
PC Hardware in a Nutshell, 2nd Edition
Upgrading and Repairing PCs
Google for Dummies
MySQL Cookbook
Teach Yourself Macromedia Flash 8 In 24 Hours
PHP CookBook
Sams Teach Yourself JavaScript in 24 Hours
PHP5 Manual
Free Games Paper Airplanes
500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele