What I am trying to do is kind of odd, but I am wondering if anyone can come up with a clever way to do what I want to do. Basically, I want to re-define a named function at runtime. I can do this with anonymous functions, but I can't figure out a way to do it for named functions. I want to do this so that I can implement a "spy" functionality on an object for a testing framework (a port of Jasmine to Flex).

Take, for instance, this class:

```
public class TestClass
{
    public var anonymous:Function = function():void { 
        trace("original anonymous"); 
    };

    public function named():void {
        trace("original named");
    }
}

```

I can easily re-define the anonymous function because it is just a variable. Javascript uses this idiom a lot. 

```
var testClass:TestClass = new TestClass();
testClass.anonymous = function():void { trace("overridden anonymous"); }

```

BUT, when I do the same thing for named functions, you get a compile-time error:

```
// Does not compile
testClass.named = function():void { trace("overridden named"); }

```

I tried to make it a bit more "squishy" but this leads to a runtime failure "Cannot assign to a method named on TestClass".

```
// Compiles with runtime failure
testClass["named"] = function():void { trace("overridden named"); }

```

Can anyone more clever than I come up with a way to hack this? Can the bytecode be hijacked? Something?