级别设置类中的错误#1010

时间:2013-07-17 21:30:41

标签: actionscript-3

我遇到了我的一段代码问题,而且似乎是在下面的课程中:

package 
{

import flash.display.MovieClip;
//levels are 11x9

public class Level extends MovieClip
{

    var level1:Array=new Array(
    1,1,1,1,1,1,1,1,1,1,1,
    1,0,0,0,0,0,0,0,0,0,1,
    1,0,0,0,0,0,0,0,0,0,1,
    1,0,0,0,0,0,0,0,0,0,1,
    1,0,0,1,0,0,0,0,0,0,1,
    1,0,0,1,1,1,0,0,0,1,1,
    1,0,0,0,0,0,0,1,1,0,1,
    1,1,1,1,1,1,1,1,1,1,1);
    var grid:Array = new Array(11);
    public function Level()
    {
        for (var i = 0; i < 9; i++)
        {
            grid.push(new Array(9));
        }
        for (var xr=0; xr<11; xr++)
        {
            for (var yr=0; yr<9; yr++)
            {
                var type = level1[yr * 11 + xr];
                var obj:Wall = new Wall(xr*50,yr*50,type);
                grid[xr][yr] = obj;
                if (type!=0)
                {
                    addChild(obj);
                }
            }
        }

    }
}
}

现在我做了一些工作,错误是错误代码#1010:术语未定义且没有属性。 更具体地说,我做了一些调试并确定了确切的行     格[XR] [岁] = OBJ; 任何帮助表示赞赏。     在此处输入代码     在这里输入代码

1 个答案:

答案 0 :(得分:1)

更改

grid.push(new Array(9));

grid[i]=new Array(9);

[编辑]

实际上试试这个

var level1:Array=new Array(
1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,1,
1,0,0,1,0,0,0,0,0,0,1,
1,0,0,1,1,1,0,0,0,1,1,
1,0,0,0,0,0,0,1,1,0,1,
1,1,1,1,1,1,1,1,1,1,1);


var grid:Array = new Array(11);
public function Level()
{


   for(var row=0;col<11;row++){
     grid[col] = new Array(9);
     for(var col=0;col<9;col++){
        var type = level1[row* 11 + col];
        var obj:Wall = new Wall(col*50,row*50,type);
        grid[col][row] = obj;
        if (type!=0){
           addChild(obj);
        }
     }
  }
}