AS Reference  :  Notes Index  :  Resources  :  About/Contact  :  Downloads

Comments

For your own sake and that of anyone who may later have to maintain or modify your Flash movie, it's good to include comments in your movie for documentation. Comments (which are not included in the published swf) can be added as separate lines, or appended to the end of a line. Comments can be included between /* and */ markers:

or following // on an individual line:

or following // at the end of an existing line:

Trace

In addition to documenting, another good way to tell what your movie is doing is to include trace statements in it. This allows you to examine (via the Output panel) the content of any variable while the movie is running. The format of the trace statement is simple:

You can include a single string, several strings concatenated with "+"s or concatenations of strings and variables as the parameter for trace. When the Flash compiler encounters a variable in the trace parameter that is not a string, it includes the command to run the class's toString function on that variable to convert it to a string before concatenating it with other strings in the parameter. When the movie is run, the parameter passed to the trace function is displayed in the Output panel. Here are some examples of trace statements. Paste this code in a new blank Flash movie and see if you get the same output shown here:

var i:Number = 5;
var street:String = "Maple Lane";
var names:Array = ["april", "may", "june"];

trace(i);    // 5

trace('the value of i is ' + i);  // the value of i is 5

trace(i + ' ' + street);   // 5 Maple Lane

trace(names);    // april,may,june (array elements separated by commas)

Intro
Flash: What & How
Example Sites
Create
Draw, Edit Shapes
Gradients
More Drawing Tips
Import
A Sample
Animate
Frames, Keyframes
Motion Tweens
More Motion Tweens
Shape Tweens
Masks
Control
Stop/Replay
Movieclips Intro
Movieclip Reference
Site Structure 1
Slideshow Movieclip
Contact Form
Scroll Resume
Preloader
Site Structure 2
Publish
Display Options
Player Detection
Optimize
AS 2.0 Basics
Intro to Syntax
Playhead Commands
Playhead Cmds 2
Coded Tween
onEnterFrame
Intro to Classes
Declare/Assign
Comments, Trace
Simple Data Types
Arrays & Objects
Code Blocks
Operators
Beyond Buttons
Code Structure
Toggle Controls
Group of Buttons
Drag and Hit
Distort Magnifier
Scroll Text
Bee Game
Dart Shooter
Sound Control
Easing Slider
Easing Slider 2
Components Intro
Timers & Delays
Dynamic Content
Intro
Drawing API
Create Text
Attach Movieclips
Easing Slider 3
Easing Slider 4
Load jpg/swf
Sliding Viewer
Preload swf
XML
Easing Slider 5
Server Comm
LoadVars (w/ PHP)
AS - PHP Lookup
Text File
Database 1:LoadVars
Database 2:Remoting
Read from directory
AS 2.0 Classes
Intro
Math
Key
Date
Color
EventDispatcher
New Samples
Pie Chart
Event-model Emailer
Tween Sequence
Fuse Sequence
SVG in Flash
Bitmap Topo
SWF as Data Holder
Two-level Menu
Yahoo! Flash Maps
Class-based Game
ASTB Samples
Disclaimer
3D Outlines
Bounce Collide
Address Book
Save Drawings
Home  :  Notes Index  :  Resources  :  About/Contact  :  Downloads