AS3 array subclass: how to get array elements (this [0] doesn't work)?

If I am a subclass of an array, how do I access an element?

class ArrayOfFoo extends Array
{
   public function getFooAt(anIndex : int) : Foo
   {
        return this[anIndex] as Foo;   //  <---- looks for an object attribute (named "0", for example)
   }
}

I could wrap the array instead of a subclass, but without the generic IArray interface, which is less useful for standard and user functions that expect an array.

Vectors do not allow subclasses at all, so they will not help.

thank

+3
source share
1 answer

Unfortunately, this is not as straightforward as you think. Check out the Array class extension in Adobe livingocs for a detailed array extension method.

+6
source

All Articles