Hi folks,
Been very busy lately but eventually I got the time to write again here. This one, I’m sure, will help some of you quite allot.
Tracing is a very common need for any application developer. It’s so frustrating when you can’t just quickly start a debugging session for the production version of your flash program. There are lots of solutions out there, but each has it’s limitations.
During the years, I developed and fine-tuned my own solution and now, it’s nearly impossible for me to start a new Flash web-app without it. Here are the features of my Debugger Console:
- the console can be embedded in the production version, you can activate it using a simple javascript command entered in the browsers’ address bar
- when the Debugger window is not open, all trace log is stored in memory until you choose to open the console, when you can see all of it in the window
- you can directly type and execute (limited) custom ActionScript code by entering commands in the console input field. The evaluated value of the output of your expression will be printed out. (printing expressions, running function, passing parameters, instantiating (new), assigning, are the main ActionScript constructs that can be parsed by the console
- command history. Use Up and Down arrow keys inside the console input field to see last used commands
Usage hints:
first type:
javascript:document.embeds[0].debug()
in your browsers’ address-bar (works in Firefox)
You’ll see the console window with all the previous traces listed. You can scroll using the keys or the mouse wheel.
Type a simple expression in the console input field (bottom of the window). For example, type stage and press Enter. Or type help to see a quick help.
To clear console, press the blue button on the top bar once. If you press it twice, the command history will also be cleared.
To close the console, press the red button. You can show it again using the javascript command above. Typically you would like to have this command stored in your bookmarks toolbar.
To assign a local variable, use:
myVar = "some text"
then you can use your local variable without “local”. simply type myVar and press Enter
Expressions are parsed with regards of type. For example 100+1 will evaluate as 101 and “100″+1 will be 1001
You can execute functions and pass them parameters. Don’t forget to make the useful methods in your application public to be able to access them from the Debugger Console.
You can even create new instances using “new” keyword. Support for “new” keyword is in early stages but it can already be used with a little extra typing. Example:(type the following commands one by one in the console)
obj = new flash.display.Shape() obj.graphics.lineStyle(0,0,1) obj.graphics.lineTo(200,200) stage.addChild(obj) listDisplay(stage)
To use the console in your web-app, just make the package com.victordramba.debug visible for your project (either by copying the package inside the project source folder or by sharing it using Project Properties -> ActionScript Build Path -> Source Path)
Known bugs and limitations:
- parsing for single quote (‘) strings is not implemented. Always use double quote (“) to pass strings.
- succesive binary operators not implemented (you can’t do e.g. 1+2+3)
Security note: Beware, if you embed the console in your production version, it will be available for other people also. Make sure you do not expose sensitive data by your application. Normally, the security wall should be on the server-side, like with any client-server web application. SWF format can be reverse engineered, so all the data inside the flash player can be considered open for the user that received it.
Example: examples/debugger
Download: example.zip


