Quantcast Programming | The Danosphere. - Part 2

The Danosphere.

Avatar

class TheDanosphere extends Dan implements Blog

Draw Dashed Lines in Flex / AS3

Here is a recent code snippet I wrote to draw dashed lines in Actionscript (I am using it in Flex). Very cool. I’m displaying it using the new “Snipt Embed” functionality from Snipt.org, pretty neat!

asdf
asp
fds
';document.write(content);
[code snippet: http://snipt.org/Jkl]

Using the Flex 3 Logging API

Using the Flex 3 logging API is not really cut and dry. It is made to be rather extensible and flexible but at the same time it manages to be completely painful and hard to understand. The Log, ILogger, LogLogger, TraceTarget, LogEvent and LogEvent level classes and be rather cumbersome.

An example of a straight up ‘log write’ would be:

var mylog:ILogger = Log.getLogger("my.package.MyClassName");
if(Log.isDebug()){
     mylog.debug("Hello from the logger");
}

This would get you [DEBUG] level output with the message “Hello from the logger”. The problem with this approach is that I wanted to be able to log from any class, without having to create ILogger instances in all classes. I also wanted the logging to be dynamic so I could hide the class package if I wanted, I also wanted the LogEvents to carry all the information that the actual ‘log write’ contained.

So I created CustomLogger and CustomLogEvent classes that are built on the pre-existing logging API. This simple goal of these classes is to make logging easier. Now you can directly call:

CustomLogger.debug("Hello from the custom_logger");

or you can access it with a Singleton instance:

var log:CustomLogger = CustomLogger.getInstance();
log.debug("Hello from the custom_logger");

So thats all good and well but how does this make things easier? By using the CustomLogger you now have FULL control over the log messages as opposed to handing them off to a Flex ILogger/LogLogger and letting it do what it will with the log messages. Also, you do not need to instantiate a new ILogger for every class that wants to write log output. Additionally the expanded CustomLogEvent class gives whatever is listening the full rundown on what is happening in terms of logging as opposed to just a glimpse.

Here is an example that shows how useful the new CustomLogger/CustomLogEvent classes are especially when it comes to directing log output to a different target (in this case, a List component).

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Best PHP Editor – Zend Studio

I’ve always written PHP code in programs like TextMate or Dreamweaver [code view] but recently after having a very good experience with an advanced Flash editor, I decided to look around for a PHP editor which offered similar benefits.

Zend Studio is great because it's offered in many formats- as a standalone or as a plug-in for the ever-popular Eclipse platform (which I'm slowly warming up to). There are probably a load of features that make Zend an awesome editor, but I'll just outline the points that make it appealing to me:

  • OOP PHP support - The editor treats object like objects!
  • Class Outline - Easily navigate large classes and find variables and functions in a snap.
  • Code Hinting - I'm all for old school coding but when it comes to reality production speed is key, and with Zend it has real-time code hinting so it not only helps out with native php classes, but also hints on any custom classes you've built within your project.
  • Real-time Compiling - discover syntax errors as you code instead of having to upload and run the code on a server every time
  • Eclipse plugin - now i can edit Actionscript and PHP in the same editor!

prev |

What's Here?