Created
March 11, 2011 09:22
-
-
Save goodbar/865663 to your computer and use it in GitHub Desktop.
an ActionScript function that uses the 'newactivation' opcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function create(target:Object, handlerFunction:Function, shouldAppend:Boolean = true, ... args) : Function | |
{ | |
var oTarget:Object; | |
var oFunction:Function; | |
var oAppend:Boolean = true; | |
var oArgs:Array; | |
var f:Function; | |
var oParams:Array; | |
var i:int; | |
var d:Dictionary; | |
var loc1:*; | |
oTarget = target; | |
oFunction = handlerFunction; | |
oAppend = shouldAppend; | |
f = check(oTarget, oFunction, oAppend, oArgs); //check() returns null if conditions not satisfied | |
if(f != null) { | |
return f; | |
} | |
oParams = new Array(); | |
while((i = 0) < oArgs.length) { | |
oParams.push(oArgs[i++]); | |
} | |
d = new Dictionary(true); | |
d["oTarget"] = oTarget; | |
d["oParams"] = oParams; | |
d["oFunction"] = oFunction; | |
d["appendParams"] = oAppend; | |
d["dFunction"] = function():* { | |
/* Apperantly arguments.callee refers to d["dFunction"] and callee.delegate refers to 'd'? */ | |
var loc1:* = arguments.callee.delegate; | |
return loc1["oFunction"].apply(loc1["oTarget"], loc1["appendParams"] ? (arguments.concat(loc1["oParams"])) : (loc1["oParams"])); | |
} | |
d["dFunction"].delegate = d; | |
delegates.push(d); //delegates is a field variable -- class variable | |
return d["dFunction"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment