I wouldn't extend either of these. Favour delegation over inheritance.

On Tue, Apr 28, 2009 at 3:23 PM, Tim Hoff <timh...@aol.com> wrote:

>
>
> Yep, thought that I could get away with not testing it.  Doesn't look like
> you can extend Array, but you can extend ArrayCollection:
>
> *package
> *{
> *     import* mx.collections.ArrayCollection;
> *
>      public* *class* MatRix *extends* ArrayCollection
>      {
> *          public* *function* MatRix(numRows:int=0,numCols:int=0)
>           {
> *                for* (*var* i:int=0;i<numRows;i++)
>                {
> *                    this*.addItem( *new* Array(numCols) );
>                }
>           }
>      }
> }
>
> Test:
>
> *var* a:MatRix = *new* MatRix(3,3);
> a[0][1] = *"test"*;
> *trace*(a[0][1]);
>
> -TH
>
> --- In flexcoders@yahoogroups.com, "smitade" <smit...@...> wrote:
> >
> > This compiles OK but fails at this point in the class:
> >
> > this[i]=new Array(numCols);
> >
> > with the error: Cannot create property 0 on [the class] i.e i being 0 on
> the first for loop when calling:
> >
> > var a:MatRix = new MatRix(3,3);
> >
>  
>

Reply via email to