AS3 snippet script for mac
Friday, November 6th, 2009I just finished the first version of a little applescript that enables you to get as3 snippets in any text editor on your mac.
Download snippets and copy it to /Library/Scripts.
Setup a short-cut… see here for an example on how to setup keyboard short-cuts. On page 3 an application called FastScripts is explained… I recommend using that.
I use the CTRL+CMD+SPACE as shortcut
When you hit your key combination you are asked to select a snippet. Press the number of the snippet you want. Then you are asked to give some parameters. Fill in the appropriate values and hit Enter. Your code will be pasted in to your editor at the cursor location.
Everytime scope is required the following can short version can be used:
pub = public
pri = private
pro = protected
sta pub = static public
sta pri = static private
The snippets:
addEventListener
parameters:
target:event (ex. myObj:Event.COMPLETE)
produces:
myObj.addEventListener(Event.COMPLETE, onMyObjComplete, false, 0, true);
private function onMyObjComplete(evt : Event):void
{
IEventDispatcher(evt.target).removeEventListener(Event.COMPLETE, onMyObjComplete);
}
removeEventListener
parameters:
target:event (ex. myObj:Event.COMPLETE)
produces:
myObj.removeEventListener(Event.COMPLETE, onMyObjComplete);
getter/setter
parameters:
name:type (ex. pub:username:String)
produces:
private var _username : String;
public function get username():String
{
return _username;
}
public function set username(value : String):void
{
_username = value;
}
var
parameters:
scope:name:type (ex. pub:username:String)
produces:
public var username : String;
function
parameters:
scope:name:return-type (ex. sta pub:getUser:User)
produces:
static public function getUser() : User
{
}
for var i
parameters:
counter:initial-value:operator:length:incrementer (ex. i:0:>:length:++)
produces:
for ( var i = 0; i > length; i++)
{
}
for var s
parameters:
key:target (ex. s:myObj)
produces:
for ( var s in myObj)
{
}
const
parameters:
scope:name (ex. sta pri:USER_READY)
produces:
static private const USER_READY : String = “userReady”;
