{"id":2928,"date":"2007-11-06T13:18:55","date_gmt":"2007-11-06T11:18:55","guid":{"rendered":"http:\/\/fdt.powerflasher.com\/blog\/?p=22"},"modified":"2007-11-06T13:18:55","modified_gmt":"2007-11-06T11:18:55","slug":"using-sos-to-debug-with-fdt","status":"publish","type":"post","link":"https:\/\/fdt.powerflasher.com\/blog\/2007\/11\/using-sos-to-debug-with-fdt\/","title":{"rendered":"Using SOS to debug with FDT"},"content":{"rendered":"<p class=\"MsoNormal\"><span lang=\"EN-US\">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.<br \/>\nIn 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.<br \/>\nLet&#8217;s start&#8230;<\/span><\/p>\n<ol>\n<li style=\"margin-bottom: 15px\">Download Powerflasher SOS from <a href=\"http:\/\/sos.powerflasher.de\/english\/english.html#downloads\" target=\"_blank\">http:\/\/sos.powerflasher.de\/english\/english.html#downloads<\/a><\/li>\n<li style=\"margin-bottom: 15px\">Download this <a href=\"http:\/\/fdt.powerflasher.com\/blog\/wp-content\/soslogger.swc\" title=\"SOSLogger-SWC\">swc<\/a> or download the sources from <a href=\"http:\/\/sos.powerflasher.de\/english\/english.html#downloads\" target=\"_blank\">http:\/\/soenkerohde.com\/2006\/11\/06\/flexas3-logging-with-sos<\/a><\/li>\n<li style=\"margin-bottom: 15px\">Start your eclipse in the FDT perspective and create a <strong>New Flash Project<\/strong> with the <strong>name <\/strong>&#8220;SOS Logging&#8221;. A good approach is to add a <strong>new folder<\/strong> to your application directory named &#8220;lib&#8221; and copy the swc-file into it.<\/li>\n<li style=\"margin-bottom: 15px\">Right-click on the swc in your <strong>lib-folder<\/strong> and choose <strong>&#8220;Source Folder&#8221;<\/strong> and <strong>&#8220;Add to Classpath&#8221;<\/strong>. Now, FDT allows you to browse through the swc in your Flash-Explorer while clicking on the little arrows in front of it.<br \/>\n<a href=\"http:\/\/fdt.powerflasher.com\/blog\/wp-content\/011.jpg\" title=\"Workfolder\"><img src=\"http:\/\/fdt.powerflasher.com\/blog\/wp-content\/011.thumbnail.jpg\" alt=\"Workfolder\" style=\"margin-top: 10px\" \/><\/a><\/li>\n<li style=\"margin-bottom: 15px\">The first part is finished. Now let&#8217;s write a little HelloWorld-application.<br \/>\nAdd a <strong>new source folder<\/strong> named &#8220;src&#8221;, create a <strong>new class<\/strong> named &#8220;SOSLogging&#8221; and write some code like the following:<\/p>\n<pre style=\"margin-top: 5px\">\npackage\n{\n     import flash.display.Sprite;\n     import flash.text.TextField;\n     import flash.text.TextFieldAutoSize;\n\n     \/**\n     * @author Stephan Partzsch\n     *\/\n     public class SOSLogging extends Sprite\n     {\n\n          public function SOSLogging() : void\n          {\n               var textField:TextField = new TextField();\n               textField.autoSize = TextFieldAutoSize.CENTER;\n               textField.text = \"Hello world!\";\n               this.addChild(textField);\n          }\n     }\n}<\/pre>\n<\/li>\n<li style=\"margin-bottom: 15px\">Now it is time to add the logging commands. First you have to create a <strong>variable of type SOSLogger<\/strong>, add a <strong>new instance of the SOSLogger<\/strong> 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.\n<pre style=\"margin-top: 5px\">\npackage\n{\n     import flash.display.Sprite;\n     import flash.text.TextField;\n     import flash.text.TextFieldAutoSize;\n     <font color=\"#333399\"><strong>import com.soenkerohde.logging.SOSLogger; <\/strong><\/font>\n\n     \/**\n     * @author Stephan Partzsch\n     *\/\n     public class SOSLogging extends Sprite\n     {\n          <font color=\"#333399\"><strong>private var _logger : SOSLogger;<\/strong><\/font>\n\n          public function SOSLogging() : void\n          {\n               <font color=\"#333399\"><strong>_logger = new SOSLogger(\"SOSLoggingClass\");<\/strong><\/font>\n\n               var textField:TextField = new TextField();\n               textField.autoSize = TextFieldAutoSize.CENTER;\n               textField.text = \"Hello world!\";\n               this.addChild(textField);\n          }\n     }\n}<\/pre>\n<\/li>\n<li style=\"margin-bottom: 15px\">As of now you can organize your work with <strong>multicoloured logging messages<\/strong>. For each command a specific colour can be defined. To customize your logging messages press <strong>Strg\/Ctrl + Y<\/strong> in your SOS.<br \/>\nThe following code shows some logging commands.<\/p>\n<pre style=\"margin-top: 5px\">\npackage\n{\n     import flash.display.Sprite;\n     import flash.text.TextField;\n     import flash.text.TextFieldAutoSize;\n     import com.soenkerohde.logging.SOSLogger;\n\n     \/**\n     * @author Stephan Partzsch\n     *\/\n     public class SOSLogging extends Sprite\n     {\n          private var _logger : SOSLogger;\n\n          public function SOSLogging() : void\n          {\n               _logger = new SOSLogger(\"SOSLoggingClass\");\n\n               var textField:TextField = new TextField();\n               textField.autoSize = TextFieldAutoSize.CENTER;\n               textField.text = \"Hello world!\";\n\n               <font color=\"#333399\"><strong>_logger.debug(\"My text: \" + textField.text);\n               _logger.error(\"My text: \" + textField.text);\n               _logger.info(\"My text: \" + textField.text);\n               _logger.warn(\"My text: \" + textField.text);\n               _logger.fatal(\"My text: \" + textField.text);<\/strong><\/font>\n\n               this.addChild(textField);\n          }\n     }\n}<\/pre>\n<\/li>\n<li style=\"margin-bottom: 15px\">All you have to do to see your first Powerflasher SOS logging message, is to <strong>start your SOS<\/strong> and then run your application by pressing <strong>Alt+Shift+X<\/strong> followed by <strong>M<\/strong>.<\/li>\n<\/ol>\n<p><span lang=\"EN-US\"> The whole project can be downloaded <\/span><a href=\"http:\/\/fdt.powerflasher.com\/blog\/wp-content\/sos_logging.zip\" title=\"SOS_Logging\">here<\/a><span lang=\"EN-US\">.<\/span><\/p>\n<p><span lang=\"EN-US\"><\/span><span lang=\"EN-US\">That\u2019s it and I hope it helps you to code your applications a bit easier.<br \/>\nStephan<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[80,179,265,288],"_links":{"self":[{"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/posts\/2928"}],"collection":[{"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/comments?post=2928"}],"version-history":[{"count":1,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/posts\/2928\/revisions"}],"predecessor-version":[{"id":6256,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/posts\/2928\/revisions\/6256"}],"wp:attachment":[{"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/media?parent=2928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/categories?post=2928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdt.powerflasher.com\/blog\/wp-json\/wp\/v2\/tags?post=2928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}