Long ago, when I started writing Actionscript, I wrote functions in the “named” variety:
function doSomething(parameter:String):Void
{
trace("MONKEYS are attacking " + parameter);
}
Then, I started writing them as named functions:
var doSomething:Function = function(parameter:String):Void
{
trace("MONKEYS are attacking " + parameter);
}
Then, I took a few Adobe training classes, and I ended up getting into the habit of writing functions like this:
this.doSomething = function(parameter:String):Void
{
trace("MONKEYS are attacking " + parameter);
}
I think the 2nd variant is just a slack-*** way of doing an anonymous function.
**What is the “best practice” for writing functions? When do I use one or the other? I know the named function syntax is important for classes (starting to write more of those now). I also know that, in AS 3.0, there were some changes to function declarations, but I want to focus on AS 2.0 here.
Any suggestions? Guidance?**
Thanks,
IronChefMorimoto