487 CHAPTER 23 Debugging and testing
showing end copy
hiding end copy
showing end copy
Something is currently: show this please
This is an effective mechanism if you want to record the value of various variables and
components.
Viewing this log file may seem cumbersome without the right tool; fortunately,
trace-log viewers are available.
23.1.4 Trace-log viewers
It’s one thing to make a log, and it’s another to view the log. Using what you have so
far, it would be tedious to continually reload flashlog.txt to see what it currently looks
like.
Fortunately third-party tools are available that do this for you by having a viewing
panel that automatically refreshes as the log file changes. You can use any generic log-
viewing tool, but here are a few we like.
■
Flash Tracer —This extension to the Firefox web browser adds a built-in panel to
Firefox, which is convenient because you don’t need to switch back and forth
between two separate applications. Price: free. https://addons.mozilla.org/en-
US/firefox/addon/3469.
■
ABLogFile Viewer —This is an open source viewer that is actively maintained. It’s
generic in nature, but it remembers the last few files opened, so it’s easy to get
back to the log file. In Windows, the application data directory is hidden, so you
may need to navigate to the directory using Explorer and drag and drop the file
into the ABLogFile Viewer. Price: free. http://www.amleth.com/ablogfile/.
■
Afterthought —This tool was developed specifically for Flash, but it hasn’t been
updated to reflect a modification in the current Flash Player that changed
where the flashlog.txt file is stored; you’ll need to edit the options to tell it
where to look. This tool is nice because it makes sure the window floats at the
front, can filter out warnings, and has handy Clear Screen and Clear Log but-
tons. Price: free. http://www.blazepdf.com/downloads/afterthought_v2_1.zip.
These log files obviously log text, but many things in Flex aren’t textual in nature, so
we’ll need a way to convert these objects into strings.
23.1.5 Converting objects to strings
Whether you’re dumping complex data types to a log file or on screen, you must
transform them into text. Flex makes this easy: most objects support a
toString
()
function that will do the conversion for you. Here’s an example:
var myNumber:Number = 32;
trace(myNumber.toString());
Commenti su questo manuale