Commando is a Flash debugger that lets you change variables at runtime and run your own custom commands. It will allow you to try out whatever tweaks you want, without the hassle of changing your code and recompiling every time. This debugger also comes with its own memory monitor, and an output panel that is similar to the output dialog in the Flash IDE.
See Commando in Action
Why Use Commando?
Using Commando you can change your code at runtime. Let's pretend you are making a platformer game. You have a jumpPower
variable, but when testing your game you feel that the player can't jump high enough. So instead of going back and changing your code, you can just type set jumpPower(25)
in Commando and you can try out the new value.
Of course, this is just a simple demonstration; Commando can be extended even more. Just continue reading...
Configuration
First, download the ZIP file included with this article. Then, add the SWC file to your project's library path.
Once you have added the SWC to your project's library path, all you need are three lines of code to add an instance of Commando on the stage:
import com.pxlcoder.debug.Commando; var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this); addChild(commando);
Now press CTRL+ENTER (CMD+ENTER on a Mac), and you will see Commando up and running in your Flash project!
Explore
Commando comes with eight built-in functions. In this section I will explain what they are and how to use them.
Math
Using the Math function you can do addition, subtraction, multiplication and division between two numbers. The Math function can also calculate the square root of a number. For example, type math 1+1
or math sqrt(144)
in the Commando dialog. The answer will show up in the output dialog.
Hide
You can use the Hide function to hide objects. You can type hide monitor
or hide output
to hide the two panels at the bottom. You can also use the Hide function with movieclips or buttons by simply typing hide myInstanceName
.
View
You can use the View function to view hidden objects. You can type view monitor
or view output
to show the two panels at the bottom. You can also use the View function with movieclips or buttons by simply typing view myInstanceName
. If any of your objects have their visible
property set to false
, typing view myInstanceName
will set it to true.
Set
Using the Set function you can set values of your variables or you can set properties of your objects. To use the Set function on variables type set myVariable(myValue)
. To use the Set function on objects, type set myInstanceName(myPropertyName,myValue)
.
Get
Using the Get function you can get the values of your variables and properties. To use the Get function type get myVariable
. You can also get properties by typing get myInstanceName.myPropertyName
.The values will show up in the output dialog.
Probe
Using the Rrobe function you can get the probe all of the properties of an object. To use the Probe function type: probe myObjectInstanceName
. The properties will be traced in the Flash IDE, rather than in the Commando output dialog.
Remove
You can use the Remove function to remove objects from the stage. To use the Remove function type remove myInstanceName
.
Add
You can use the Add function to add objects back on to the stage. To use the Add function type add myInstanceName
.
Note: Commando's built-in functions each evaluate a single string, so after you type your function name and press space, make sure to type your arguments without any spaces. Instead, type your arguments as one continuous word, with commas if necessary.
Extend
While Commando has many great built-in functions, you may want something more. To solve this problem, Commando comes with a function to add your own custom commands.
Here is a quick code example of how you can create your own custom commands:
import com.pxlcoder.debug.Commando; var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this); addChild(commando); commando.addCommand("output", outputFunction); //Sets the command keyword to "output" and calls the outputFunction below public function outputFunction(s:String):void { commando.output(s); //A call to Commando's built-in output dialog }
Now press CTRL+ENTER (CMD+ENTER on a Mac), to run your code. In the Commando dialog, type output hello
, and press Enter. The output dialog will now say hello!
You can also remove commands from Commando by using the removeCommand()
function.
import com.pxlcoder.debug.Commando; var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this); addChild(commando); commando.removeCommand("output");
Recap: Commando has three functions that you can access; addCommand()
, output()
and removeCommand()
.
Conclusion
At the end of the day, debugging is the most important part in the development process. Commando has everything you could ever ask for in a debugger. You can use it for anything and everything.
If you're a Tuts+ Premium member, you can download the source files for Commando - just log in and head to the Source File page.
Any questions, comments or concerns? Feel free to get in touch in the comments.
Take control of your Flash projects!
Comments