|[ LiB ]|
I'm about to introduce a command that will be your close friend throughout your Flash development career. It is called the trace command. Don't worryit has nothing to do with drawing or tracing paper. What the command does is simply output information into a special window called the Output Window.
Remember the debugging stage I discussed in the last chapter? The trace command will be one of the many tools that you will be using to find bugs in your programs.
Now is actually a perfect time to introduce the proper syntax for the commands that you will be using so often. Remember the opening and closing parentheses with the ending semi- colon at the end of the command line? Let's talk about these.
Always use a semi-colon to separate commands. Even though Flash is sometimes lenient with this rule, there is no excuse for sloppy pro gramming. As a rule of thumb, always end a command with a semi colon.
First off, all commands are separated by semi-colons. There is usually a command per line, so you'll usually see the semi-colons at the end of each line.
Most built-in actions and commands end in a function call. Executing a command can sometimes be referred to as "calling the command" or "calling the function." This function call is denoted by parentheses(). This tells Flash to execute the built-in command. Later on, I will show you how to build your own command set. Let's look at an example:
You can see above that I typed in the name of the command, the function call notation (the parentheses), and the semi-colon. Once this command is typed into the main Timeline in the Actions Panel (in Expert Mode), you will be telling Flash to output something to your Output Window.
Back up a second. I stated previously that the trace command outputs information to the Output Window. What will it display? The answer is: nothing. That's because there is a syntax error. So where's the error? In order for Flash to display some result, the command must include a parameter . A parameter is simply additional information within the parentheses.
So how do we format this parameter information so Flash doesn't complain? What's the complete syntax for the trace command?
trace("Text to be displayed!");
The line above is written correctly and Flash will have no problem interpreting this code and displaying "Text to be displayed!" This is an example of proper usage of this command. You can easily make it display something else by replacing the text in between the quotation marks like this:
|[ LiB ]|