Can't Override Array Methods

Hello everyone. I have a couple of concerns with this Array subclass I’m writing (it’s not finished and please do not ask me why I didn’t use ObjectProxy or Proxy as the base class).


package com.cation.rgd.utils {

    public dynamic class RectArray extends Array {
        
        override AS3 function indexOf(searchElement:*, fromIndex:int = 0):int {
            // Return the index of an element WHEN the array is straightened
            return straighten().indexOf(searchElement, fromIndex);
        }
        
        override AS3 function join(sep:* = ","):String {
            sep = Object(sep).toString();
            // Create an empty string
            var string:String = "";
            for (var i:Number = 0; i < length; i++) {
                if (this* is Array) {
                    for (var j:Number = 0; j < this*.length; j++) {
                        // If array, iterate once and obtain column elements
                        string += this*[j].toString();
                        if (j != this*.length - 1) {
                            // If not at end of array, put separator
                            string += sep;
                        }
                    }
                    if (i == length - 1) {
                        // If at end of array, make a newline
                        string += "
";
                    }
                }
                else {
                    // If not array, string the element and make a newline
                    string += this*.toString() + "
";
                }
            }
            return string;
        }
        
        override AS3 function lastIndexOf(searchElement:*, fromIndex:int = 0x7fffffff):int {
            // Return the last index of an element WHEN the array is straightened
            return straighten().lastIndexOf(searchElement, fromIndex);
        }

    }
}

I’ve cut out the other methods and properties (they do exist: RectArray.straighten() returns an Array, just so you know) because they aren’t the trouble-makers.

According to three AS3 references (the Flex 2, Apollo Alpha, and Flash CS3), the method Array.join takes one argument, sep:* with no default value (technically, the default value is a comma, but it’s not implemented as a default value, at least that’s what it looks like on the references).

So, naturally when I override it, I’m supposed to keep the same arguments and when I did, Flash would not compile it saying it was an incompatible override.

I added the default value of “,” and it compiled (in fact, any string worked). So, obviously there’s something different about the internal implementation of the actual method…either that or it’s just me.

Second, I can’t override Array.indexOf and Array.lastIndexOf and I can’t figure out why. I’ve tried it in Flash and the Flex SDK and it doesn’t work no matter what I do.