Collecting and identifying functions within an array in actionscript <p>So, I want to do something where I collect functions to be invoked later when a certain condition is met. E.g.</p> <pre><code>function doSomething(someArg:Object):void { if (conditionIsFalse){ operationsToDoWhenConditionIsTrue.push(function(){ doSomething(someArg); }); } } function onConditionBecomingTrue():void { while (operationsToDoWhenConditionIsTrue.length &gt; 0){ operationsToDoWhenConditionIsTrue.shift()(); } } </code></pre> <p>So far so good. However at some point I want to iterate over the operationsToDoWhenConditionIsTrue and identify and replace a function. In pseudo code inside the doSomething method it would be:</p> <pre><code>function doSomething(someArg:Object):void { if (conditionIsFalse){ for (var i:int = 0; i&lt;operationsToDoWhenConditionIsTrue; i++){ // pseudo code here if (typeof operationsToDoWhenConditionIsTrue[i] == doSomething){ operationsToDoWhenConditionIsTrue[i] = doSomething(someArg); } } } } </code></pre> <p>Basically if doSomething is called twice, I only want operationsToDoWhenConditionIsTrue to hold the most recent invocation. Obviously since the invocations are wrapped in function(){} all the functions are the same. Is there any way I can accomplish what I want?</p>