30 May 2010

Sans serif font improves code editor readability

In Windows, I often use Courier New font for my code editor since it is the default monospace font which support a decent range of Unicode characters. However, the Courier New is a typewriter-like font which is somehow difficult to read because of its short, broad face with over-emphasized serifs. (Serif: a short line at the end of the main strokes of a character).

In Ubuntu, the default editor font in Eclipse is Monospace which is a sans-serif font. (Sans serif is a type of font without serif). To my observation, this font is much more legible than Courier New especially when the characters are small in size. Sadly, the font doesn't support many Unicode letters especially Vietnamese and extended Latin. Looking around in Ubuntu's default font sets, I've found WenQuanYi Micro Hei Mono. This sans serif monospace font contains a broad range of Unicode letters including Vietnamese and other East Asian languages. This is exactly what I'm looking for in terms of readibility and Unicode support.

To my studies, WenQuanYi Micro Hei is an open source derivative of Droid Sans Fallback and is powered by many Linux distros. As you may guess, Droid Sans is the font for the hottie mobile platform - Android. Windows users can download WQY Micro Hei font here (The file format is a true type collection .ttc).

Here's the screenshot of Courier New (top) and WQY Micro Hei Mono (bottom) both in size 11pt, 100% zoom:

monospace_compare.jpg

18 May 2010

Demystify the “root” property of DisplayObject

Every DisplayObject has a property named “root”. What does this property refer to? Do all display objects share the same root object?

According to Adobe’s Help, the root property is the top-most display object in the portion of the display list's tree structure represented by that SWF file. In other words, root is the document class of that SWF. (By saying document class, I mean the movie clip that is linked with document class in Flash CS or the target class which you compile with Flex SDK)

There are other cases mentioned in the document:

  • Root of Stage is the Stage itself.
  • Root of a loaded image (jpg, png, gif) whose content is a Bitmap is the Bitmap.
  • If a DisplayObject is created by code and (for e.g. new Sprite()), its root is null until it is added to a container which has non-null root. (The container’s root will be passed to its child). The container is not necessary to be on stage.

11 May 2010

Using Flash Proxy Class

According to Adobe’s Help, the Proxy class (flash.utils.Proxy) lets you override the default behavior of ActionScript operations (such as retrieving and modifying properties) on an object.

The usage note sounds interesting but this is one of the least used classes in AS3. In fact there are some use cases of this class which prove it is extremely powerful and may help you save many lines of code. Some of those are:

  • OrderedObject: an object whose properties order are strictly maintained.
  • TraversableObject: an object which allow you to traverse through its declared properties by using for loop.

First let’s see how to use it.

05 May 2010

Featured Presentation – Quick As A Flash

“One hundred slides on Flash optimization, covering general theory, code, media, and graphics,” by Grant Skinner.

Click to open the slides in a new window

These slides are recommended to any Flasher who seeks for serious code optimization and extreme performance improvement.

Note: When entering the page, press Left or Right to navigate the slides.