Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 help.

Thanks

like image 776
Richard Haven Avatar asked Apr 19 '26 03:04

Richard Haven


1 Answers

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.

like image 121
taskinoor Avatar answered Apr 21 '26 06:04

taskinoor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!