Ah, I see the problem.  If j is greater than i, it will fail.  How about
this:

public class MatRix extends Array
{
public function MatRix(numRows:int=0,numCols:int=0)
{
      super(numRows);

      for (var i:int=0;i<numRows;i++)
      {
           this[i]=new Array(numCols);
      }
}

-TH

--- In flexcoders@yahoogroups.com, "Tim Hoff" <timh...@...> wrote:
>
>
> Sorry, i meant:
>
> this.push ( new Array() );
>
> -TH
>
> --- In flexcoders@yahoogroups.com, "Tim Hoff" TimHoff@ wrote:
> >
> >
> > Have you tried something like this:
> >
> > this.addItem( new Array() );
> >
> > -TH
> >
> > --- In flexcoders@yahoogroups.com, "smitade" smitade@ wrote:
> > >
> > > I'm trying to extend an Array into a 2D matrix. Any suggestions?
The
> > following code fails but I don't understand why.
> > >
> > > public class MatRix extends Array
> > > {
> > > public function MatRix(numRows:int=0,numCols:int=0)
> > > {
> > > super(numRows);
> > > for (var i:int=0;i<numRows;i++)
> > > {
> > > for (var j:int=0;j<numCols;j++)
> > > {
> > > this[j]=new Array();
> > > }
> > > }
> > > }
> > >
> >
>



Reply via email to