Posts tagged ActionScript
Formatting your Flex code in Flex Builder 3
Jul 9th
Oftentimes i will be searching the net for a useful class or code snippet, only to be horrified by its inherently ugly formatting. I’m obsessed with code neatness and readability, and it really pisses me off when i have to reformat an entire class by hand.
Enter Flex Formatter from Ernest Pasour
This incredibly useful little set of three plugins for Flex Builder 3 (and possibly Flash Builder 4 – i haven’t tried yet, can someone confirm this?) provides you with a vast variety of code formatting options. Below is a couple of screenshots of the configuration pages:
ActionScript
MXML
Even apart from all of its amazing code reformatter tools, FlexFormatter 0.6.24 has the ability to generate ASDoc comments! By now you should be convinced, so here’s the installation process:
- Download zip file from here
- Unzip contents (3 .jar files) to your plugins directory inside of your Flex Builder 3 installation
- Restart Flex Builder and you will notice there will be 5 new buttons in your toolbar:
Happy formatting!
Succinct Singletons
Feb 11th
A singleton can be a very useful and essential Object-Oriented device in many instances (no pun intended). Singleton classes only allow one instance of that particular class, and this can be very useful in situations where you want one object to be used throughout your Flash/Flex application instead of many separate ones. I usually use singleton classes for classes that merely act as utility proxies to my applications.
Below is the code to create a very succinct singleton
package { public class Singleton { private static var _instance:Singleton; public static function getInstance():Singleton { if(!_instance) _instance = new Singleton(); return _instance; } } }
In the upcoming API i’m planning on releasing, i’ll be using Singletons extensively, and the API will – of course – be open source.

