Advertisement
Workflow

Free Flash Debugger: Commando (With Premium Source Files)

by

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.

The Library Path Dialog

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!

Commando says 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!

Related Posts
  • Code
    Web Development
    PHPStorm: When the IDE Really MattersPhpstorm preview
    The IDE that you choose to use day in and day out, can make a big difference in your web dev workflow. PHPStorm offers many wonderful features to improve this process, let's take a look!Read More…
  • Computer Skills
    Alfred
    Alfred DebuggingAlfred400
    No matter how hard I try, I still have problems with scripts that I write. No matter the approach taken, mistakes in typing, logic, or both will cause programs to not behave the way expected. Debugging is the art of finding and removing these mistakes. In Alfred, debugging is even harder due to the scripts being executed in a sub-process. You need the skills this tutorial will teach.Read More…
  • Game Development
    Implementation
    Write Once, Publish Everywhere With HaxePunk: Making a GamePreviewretinaimage
    You've probably had this experience before: you hear about an awesome game, but then you find out that it's only coming out on the one platform that you don't own. It doesn't have to be this way. In this tutorial, you will learn how to use Haxe to make a game in one development platform that can target multiple gaming platforms, including Linux, Mac, Windows, iOS, Android, and Flash.Read More…
  • Code
    Corona SDK
    Build A Poker Game in Corona: Interface SetupOd95a preview image@2x
    In this two-part tutorial, I will show you how to build a poker game using the Corona SDK. You will learn about touch controls, tweening elements, timers, and how to create a custom sort function.Read More…
  • Code
    JavaScript & AJAX
    Creating Brackets ExtensionsDeeper in brackets retina preview
    A little while ago I wrote about the recent updates to the Brackets editor. Brackets is an open source project focused on web standards and built with web technologies. It has a narrow focus and therefore may not have a particular feature you've come to depend upon. Luckily, Brackets ships with a powerful extension API that lets you add any number of new features. In this article, I'm going to discuss this API and demonstrate how you can build your own extensions.Read More…
  • Code
    JavaScript & AJAX
    Testing in Node.jsNodejs testing chai retina preview
    A test driven development cycle simplifies the thought process of writing code, makes it easier, and quicker in the long run. But just writing tests is not enough by itself, knowing the kinds of tests to write and how to structure code to conform to this pattern is what it's all about. In this article we will take a look at building a small app in Node.js following a TDD pattern.Read More…