Hi!
I have problems defining indexed array with actionscript.
The task is following. I have a board of point objects. I need to store them into one array, so I can access each point using simply it x,y coordinates. for example to get point one I want to be able use points[1][1], etc. I read the doc here http://livedocs.adobe.com/flex/3/html/help.html?content=10%5FLists%5Fof%5Fdata%5F2.html, and realized that I don't understand how to initialize array for my needs. (Especially when it can contain from 10 to 15 rows and columns, so it will be quite hard to use following notation: masterTaskList[0] = ["wash dishes", "take out trash"];, as suggested in docs.)
What I am doing is:
for (var x:Number = 1; x<= boardSize; x++)
{
for (var y:Number = 1; y<= boardSize; y++)
{
var stone:StoneSprite = new StoneSprite();
stone.x = this.x + x*cellWidth;
stone.y = this.y + y*cellWidth;
stones[x][y] = stone;
}
}
But it gives me an error:
RangeError: Index '1' specified is out of bounds. at mx.collections::ListCollectionView/getItemAt()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:422] at mx.collections::ListCollectionView/http://www.adobe.com/2006/actionscript/flash/proxy::getProperty()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:698] at components::Board/placeStonesInNodes()[/Users/oleg/jin/goclub/trunk/goapp/usersList/src/components/Board.as:60] at components::Board/creationComplete()[/Users/oleg/jin/goclub/trunk/goapp/usersList/src/components/Board.as:44] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent()
Could you please suggest me a way to solve my problem