flash - Two Dimension Array with Custom Type Elements -


i'm trying create on scene n x n size matrix, each element should movie clip, named table, prepared in library.

var tables:array.<table> = new array.<table>(tablesdimension, tablesdimension);  (var i:int = 0; < tablesdimension; i++) {     (var j:int = 0; j < tablesdimension; j++) {         var temptable:table = new table();         temptable.x = * 150 + 100;         temptable.y = j * 100 + 100;         stage.addchild(temptable);         tables.push(temptable);         trace(tables[0][0].x);     }    } 

a movie clip (in case, table) cannot put in 2 dimensional arrays? should use type conversion in last line, @ trace(tables[0][0].x); suggest compiler: it's table type object?

the error message receive: "type parameters non-parameterized type"

i'm not sure why you're trying first line it's incorrect. quote adobe actionscript reference:

the array() constructor function can used in 3 ways.

see adobe reference link on array creation. or can use vectors (which typed, seem want have).

so want create array, contain arrays. need create arrays contained in when go through first one. else try push non existing elements. also, need add index rst said.

var tables:array.<table> = new array();  (var i:int = 0; < tablesdimension; i++) {      tables[i] = new array();     (var j:int = 0; j < tablesdimension; j++) {         var temptable:table = new table();         temptable.x = * 150 + 100;         temptable.y = j * 100 + 100;         stage.addchild(temptable);         tables[i].push(temptable);     } }         trace(tables[0][0].x); 

should work.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -