
359
USING FLASH CS4 PROFESSIONAL
ActionScript
If you use the
trace()
statement in your scripts, you can send specific information to the Output panel as the SWF
file runs. This could include notes about the SWF file’s status or the value of an expression. For more information, see
the
trace()
function in the
ActionScript 2.0 Language Reference
at
www.adobe.com/go/learn_fl_cs4_as2lr_en
.
Display or hide the Output panel
❖
Select Window
> Output or press F2.
Work with the contents of the Output panel
❖
In the Output Panel menu
, select a command. Here is a partial list:
Copy
Copies all the contents of the Output panel to the computer's Clipboard. To copy a selected portion of the
output, select the area you want to copy and then select Copy.
Save To File
Saves the Output panel contents to a text file.
Filter Level
Select None to prevent any information from appearing in the Output panel; select Verbose to send all
information to the Output panel.
Use the trace statement
A
trace()
statement sends specific information to the Output panel. For example, while testing a SWF file, you can
send results to the Output panel when a button is pressed or a frame plays. The
trace()
statement is similar to the
JavaScript
alert
statement.
When you use the
trace()
statement in a script, you can use expressions as parameters. The value of an expression
appears in the Output panel in the test environment.
1
Select a frame in the Timeline and add a
trace()
statement. For example, you might select Frame 1 and add the
following ActionScript 2.0 code:
this.createEmptyMovieClip("img_mc", 10);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
trace(ta" loaded in "+getTimer()+" ms");
};
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String,
httpStatus:Number) {
trace(">> error downloading image into "+target_mc);
trace(">>\t errorCode="+er", httpStatus="+httpStatus);
};
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/404.jpg", img_mc);
2
Select Control > Test Movie to test the SWF file.
The Output panel displays the results of the
trace()
statement. For example, the panel might display the following
message:
Updated 5 March 2009