Expert Mode

I l @ ve RuBoard

Now that you have learned to use the Actions panel in Normal mode, it is already time to advance to Expert mode. This is the recommended mode and the one that most ActionScript programmers use.

In Expert mode, you don't need to use the category list to the left. Instead, you can just type the keywords that you want to use. Because the Actions panel allows you to type almost anything, it is easy to make mistakes.

However, you can still use the category and keyword list to the left to insert standard ActionScript commands, functions, and operators. It also comes in handy when you can't quite remember a command, or how to spell it.

Switching Modes

To switch to Expert mode, you can use the little pop-up menu in the upper-right corner of the Actions panel. The first two choices are Normal Mode and Expert Mode. Switch it to Expert Mode.

You can also use the keyboard shortcuts Command+E and Command+N on the Mac and Ctrl+E and Ctrl+N in Windows to switch between Normal and Expert modes. However, make sure that the Actions panel is the frontmost window, with full focus. Otherwise, these keys will map to File, New Document, and Edit, Edit Symbols in the menu.

Figure 2.5 shows the Actions panel in Expert mode. The area of custom command parameters disappears, as well as the short definition area. Instead, the main code typing area takes over almost the whole right side of the screen.

Figure 2.5. The Actions panel in Expert mode includes a larger area for typing in code.

graphics/02fig05.jpg

Switching from Normal to Expert mode is easy and always works. However, switching from Expert to Normal mode works only if there are no syntax errors in your code. This is a shame because I find that I often want to switch to Normal mode to have access to the helper forms at the bottom of the window. However, unless I have already correctly formatted the command or function I am working on, Flash won't let me switch. Then, after I have found the correct format, I no longer need to switch.

The Actions Panel Pop-Up Menu

The Actions window pop-up menu has several other commands that will be useful while you use the Actions panel, especially in Expert mode.

You can use the standard find and replace functions to search through your code. The keyboard shortcut Command+F on the Mac and Ctrl+F in Windows quickly brings up the Find dialog. The keyboard shortcut Command+H on the Mac and Ctrl+H in Windows brings up the Replace dialog. You can also find something once and then press F3 to find its next occurrence.

Another function in this menu is the Goto Line function, which quickly takes you to a specific line number.

The Check Syntax function looks at the script in the window and determines whether there are any obvious errors. If it doesn't find any, you get a message that says This script contains no errors .

graphics/book.gif

Often, this message lies to you. The Check Syntax function determines only whether there are any obvious errors with your code. It does not try to run your code to see whether it is viable . Therefore, it is easy to write code that results in an error that will not be caught by the Check Syntax function. Each line of the code is correct, but taken as a whole, there is a problem.


Still, the Check Syntax function can come in handy, especially for beginners . It catches things such as the misuse of operators or a missing bracket .

The Auto Format and Auto Format Options menu choices relate to the fact that Flash is always cleaning up your code as you type it. It indents the code and colors it in. You can change how this works with the Auto Format Options dialog, shown in Figure 2.6.

Figure 2.6. The Auto Format Options dialog allows you to customize how Flash formats your code.

graphics/02fig06.gif

In addition, selecting the Preference menu option lets you select the colors that Flash uses in your code, the indentation width, and even the font used in the Actions panel. You can also get to this dialog by choosing Edit, Preferences and then selecting the ActionScript Editor tab. Figure 2.7 shows this dialog.

Figure 2.7. The Preferences dialog allows you to customize how the ActionScript Editor displays your code.

graphics/02fig07.jpg

Script colorization is a great help when programming. When this is on, you'll see official ActionScript keywords in one color , with constructs that you create, such as variable names and values, in another color. This can be a great help for beginners, as a correctly typed keyword such as gotoAndPlay should turn blue as soon as you type it. If it does not, then you may have mistyped the command.

The remaining options in the Actions panel pop-up menu allow you to export or import text files. This means that you can write your scripts in a text editor of your own choice and then import them into Flash. You can also print your script using this menu.

I don't recommend writing your code in another program. The Actions panel is not the fastest text editor in the world, but you can only write code so fast anyway. It is much better to write scripts inside the Flash environment where you can quickly refer to the keyword category list, the names of your movie clips, and the names and locations of frames . Plus, you can quickly switch between different scripts stored in different locations inside the Flash movie.

Typing Code in Expert Mode

Ironically, the Actions window is simpler to use in Expert mode than in Normal mode. This is because all you need to do is type; there are no forms to fill out at the bottom of the window. It is just a simple text editor.

The downside is that it is also much easier to make mistakes. In Normal mode, Flash keeps you in line. But in Expert mode, you are free to mistype command names or put the wrong parameters in the wrong place.

In Expert mode, you simply place the cursor in the typing area and type away. Flash doesn't leave you completely on your own, however. Your text will automatically be formatted with indentations. The different keywords will also follow the color scheme specified in the preferences.

You can also use the button that looks like a check mark to check your script for obvious syntax errors. The formatting button next to it will format all your script, although each line will automatically format after you press Return on the Macintosh or Enter in Windows.

The Actions panel also contains a great help function called Code Hints. These are little pop-up menus that appear as you are typing. You can ignore them and keep on typing, or you can use them to select from a list of options. You will notice these Code Hints as you use the Actions panel more and more.

I l @ ve RuBoard


Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

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