If you code Flash and ActionScript you usually rely on the trace() function for debugging. A much better way is to use the free Powerflasher SOS (SocketOutputServer) which is a XML Socket server with a graphic user interface. Together with the mx.logging framework it is predestinated for logging and debugging your application and of course SOS can be used as a logging tool per se.
In the internet you can find a few classes to enable communication of your application with SOS. Of course you can write your own logging classes but in this tutorial the debugging will be explained using the classes written by Soenke Rohde. In the following debugging tutorial you will see how easy and useful working with SOS is and how much better it looks like normal trace() messages.
Let’s start…
- Download Powerflasher SOS from http://sos.powerflasher.de/english/english.html#downloads
- Download this swc or download the sources from http://soenkerohde.com/2006/11/06/flexas3-logging-with-sos
- Start your eclipse in the FDT perspective and create a New Flash Project with the name “SOS Logging”. A good approach is to add a new folder to your application directory named “lib” and copy the swc-file into it.
- Right-click on the swc in your lib-folder and choose “Source Folder” and “Add to Classpath”. Now, FDT allows you to browse through the swc in your Flash-Explorer while clicking on the little arrows in front of it.

- The first part is finished. Now let’s write a little HelloWorld-application.
Add a new source folder named “src”, create a new class named “SOSLogging” and write some code like the following:
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
/**
* @author Stephan Partzsch
*/
public class SOSLogging extends Sprite
{
public function SOSLogging() : void
{
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.CENTER;
textField.text = "Hello world!";
this.addChild(textField);
}
}
}
- Now it is time to add the logging commands. First you have to create a variable of type SOSLogger, add a new instance of the SOSLogger to it and pass the name of your class. That allows you to see which class generates which logging-message. The added code is highlighted in the following example.
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import com.soenkerohde.logging.SOSLogger;
/**
* @author Stephan Partzsch
*/
public class SOSLogging extends Sprite
{
private var _logger : SOSLogger;
public function SOSLogging() : void
{
_logger = new SOSLogger("SOSLoggingClass");
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.CENTER;
textField.text = "Hello world!";
this.addChild(textField);
}
}
}
- As of now you can organize your work with multicoloured logging messages. For each command a specific colour can be defined. To customize your logging messages press Strg/Ctrl + Y in your SOS.
The following code shows some logging commands.
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import com.soenkerohde.logging.SOSLogger;
/**
* @author Stephan Partzsch
*/
public class SOSLogging extends Sprite
{
private var _logger : SOSLogger;
public function SOSLogging() : void
{
_logger = new SOSLogger("SOSLoggingClass");
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.CENTER;
textField.text = "Hello world!";
_logger.debug("My text: " + textField.text);
_logger.error("My text: " + textField.text);
_logger.info("My text: " + textField.text);
_logger.warn("My text: " + textField.text);
_logger.fatal("My text: " + textField.text);
this.addChild(textField);
}
}
}
- All you have to do to see your first Powerflasher SOS logging message, is to start your SOS and then run your application by pressing Alt+Shift+X followed by M.
The whole project can be downloaded here.
That’s it and I hope it helps you to code your applications a bit easier.
Stephan
I’m kind of disappointed that a very basic and essential debugging option like “Trace” is not available in FDT.
Trace is the simplest, easiest way to check simple AS scripts. I don’t need a complete logging system that needs documentation just to use it.
I don’t want to install monsterdebugger because I thought FDT was a complete coding environment.
If I have to spend days just getting an equivalent of “Trace” to work, that doesn’t bode very well for more complex operations does it?
So if any FDT developer is reading this: please enable Trace actions, and don’t expect devs to pay 350 just for one simple debugging function.
Opa Bokma.
this tutorial is only for developers using AS3. What about supporting those of us that have to use AS2?
Also, this tutorial is only for users with full versions of FDT enterprise. If you have FDT pure you will not be able to browse the contents of the swc.
I am desperate for a tutorial for AS2 projects. Any ideas?
@paul Because Monster Debugger trace listing sux, and because it’s done in air so perfs are kinda poor.
Why not just use Monster Debugger, easier, quicker, simpler:
http://demonsterdebugger.com/
[…] There are a few AS libaries to make SOS more friendly. This FDT post covers one of them. […]
You do not have to unzip the linked file because it is the swc-file.
Nevertheless when you unzip the swc you see that library.swf and catalog.xml are in it. But all you need is the whole swc.
The link to the swc file when unzipped has only library.swf in it. Where is the swc?
Hello together, here are some answers to your questions…
@C4RL05:
It is possible to configure your colors by pressing Strg/Ctrl + Y in your SOS. Make sure that all checkboxes are checked so that you can see your definded color. Does this solve your problem?
@Ronzoni:
Unfortunately SOS does not work with MACs. There are some alternatives but I am not sure how well they work.
A short time ago I read about a tool which allows you to show your logging messages in firefox. It is named “Thunderbolt” and you can find further informations here
->http://code.google.com/p/flash-thunderbolt/wiki/ThunderBoltAS3
Furthermore a friend told me that there are some other good tools, which you can find under the following urls:
-> http://osflash.org/luminicbox.log
-> http://osflash.org/projects/alcon
@Arie de Bonth:
I think that is possible and the informations on this page should help you to realize your project. Hope that helps.
-> http://sos.powerflasher.de/english/english.html (see FAQ)
Hi, this tool is working fine.
I’ve one question: Is it possible to send messages from SOS to a flash client? Because it is an ideal tool to test my socket protocol.
Is there any MAC-supported alternative to SOS?
That’s really good, thanks for the tutorial.
The only thing I don’t see is different colours in SOS. Do I have to configure it?