Skip to content

Instantly share code, notes, and snippets.

@djcsdy
Created February 24, 2012 00:15
Show Gist options
  • Save djcsdy/1896016 to your computer and use it in GitHub Desktop.
Save djcsdy/1896016 to your computer and use it in GitHub Desktop.
Object closure allocation in AS3
class Foo {
function hatstand():void {}
function lampshade():void {
Tablecloth.onRemove(hatstand); // <- this allocates
}
}
class Foo {
var f:Function;
function Foo() {
f = hatstand; // <- this allocates
}
function hatstand():void {}
function lampshade():void {
Tablecloth.onRemove(f); // <- and this doesn't allocate
}
}
class Foo {
var f:Function;
function Foo() {
f = hatstand; // <- this allocates
}
function hatstand():void {}
function lampshade():void {
Tablecloth.onRemove(hatstand); // <- this doesn't allocate either, for some reason
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment