1

Say just for fun I want to override Array and redefine map:

public dynamic class MagicArray extends Array {
  public override function map(f:Function, thisObject:* = null):Array {
    var result:Array = [];

    for (var i:int = 0; i < this.length; i++) {
      result.push(f(this[i]));
    }

    return result;
  }
}

We get this error: Method marked override must override another method.

Huh?

So I stripped the override keyword and tried again. Now, everything compiles fine. But if we try to use it:

var a:MagicArray = new MagicArray([1,2,3]);
a.map(function(x) { return x + 1; }); 

We get the following error:

Error: Ambiguous reference to map.

So what's going on here? How can I override map?

1
  • Interesting idea of fun, maybe consider a hobby :-), really though not sure I'll see if I can dig up anything about map Commented Jul 3, 2012 at 21:20

1 Answer 1

1

Did you make the extension dynamic and are you using the namespace see here http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b8d829-7fde.html

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah that's the one. Darn, I had seen that link before but forgot all about that crazy AS3 override stuff. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.