var someFunction:Function = function():void{}
will run slower than
public function someFunction():void{}
Whether the difference is enough that it matters is a completely different story. I think that in the use of variables with typed variables, temporary callbacks for โeventsโ (Not Flash AS3 Events, but the general meaning of the word โeventโ) are important, which do not occur once in an update cycle. Even inside the update cycle, this strategy is much more convenient to use than using the Flash-based event dispatch model (especially if you use event bubbles, which is an absolute pig).
Of course, it can also refer to Demeterโs Law, which is a means of encapsulating deeply nested is-a relationships, so you don't care if doFoo () requires 10 references to objects and functions calls under the hood while foo is running . Demeter's law can be very intense depending on how deep the call stack is when you call doFoo ().
As for the question in your comment, it's easy enough to check yourself. In fla:
// on frame 1 var textField:TextField = new TextField(); this.addChild(textField); var f:Function = this.stop(); var i:int = 0; var ilen:int = 100000; var time:int; time = getTimer(); for(i = 0 ; i < ilen ; i++){ f(); } time = getTimer() - time; textField.text = "f() :: "+String(time)+"\n"; this.gotoAndStop(2); // on frame 2 var mc:MovieClip = new MovieClip(); time = getTimer(); for(i = 0 ; i < ilen ; i++){ mc.stop(); } time = getTimer() - time; textField.appendText("mc.stop() :: " + String(time)); this.stop();
I have not tested this, so there may be syntax errors. Of course, you will need the right imports. This should be logical.
Be sure to check this out in the browser, not just the debug player or the preview player. Your browser plugin will have higher performance, as well as, most likely, what the end user has on his machine.
source share