If you have Flash Builder Burrito (ver 4.5), it now has support for code templates (or code snippets). I’ve created a few that I thought I’d share:
Custom event class
Custom events are sort of a pain in the ass. You’ve got to remember the syntax then copy the name of the class and the variables like a million times to create them. With this code snippet, I just create a new blank actionscript file in the right folder. Open it and type ce, then Ctrl-Space. Then I type the name of the class, which is automatically copied to all the different spots it needs to go, along with the constants and variables for that class.
Key Trigger: ce
Code Template:
package ${enclosing_package} { import flash.events.Event; public class ${event_name} extends Event { public static const ${event_type}:String = "${event_type_camel}"; public var ${event_variable_name}:${event_variable_type}; public function ${event_name}(type:String, ${event_variable_name}:${event_variable_type}) { this.${event_variable_name} = ${event_variable_name}; super(type, true); } override public function clone():Event { return new ${event_name}(type, ${event_variable_name}); } } }
Trace variable name and label
This snippet allows you to quickly trace a variable’s name and value in the least amount of keystrokes. Type tv, then Ctrl-Space, and paste or type in your variable name. It will be look like this:
trace("_yourVar: "+_yourVar);
Key Trigger: tv
Code Template:
trace("${var}: "+${var});
Trace function name
This snippet allows you to easily trace the function (or method) name of the function you are in.
Key Trigger: tf
Code Template:
trace("${enclosing_method} ");