Subclassing an AS3 Array: how to get array elements (this[0] does not 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 an array instead of subclassing it, however lacking a universal IArray interface, that is less than useful for standard and custom functions expecting an Array.
Vectors do not allow subclassing at all, so they won't hel开发者_开发知识库p.
Thanks
Unfortunately this is not as straight forward as you think. Check Extending the Array class on Adobe livedocs for the detail method of extending an array.
精彩评论