1
我遇到了我的程序使用addChild問題
工作,文檔類都按這樣的:的addChild沒有內部功能
public function gridtest()
{
turn++;
var plusX = 1;
var plusY = 0;
trace ("game started");
var i;
var j;
for (i = 0; i < 5; i++)
{
trace ("first for loop");
for (j = 0; j < 8; j++)
{
gridbutton = new GridButton();
gridbutton.x += plusX;
gridbutton.y += plusY;
gridbutton.GBID = (i*10)+ j;
trace ("created button at " + plusX + "," + plusY);
addChild(gridbutton);
GBList.push(gridbutton);
trace("grid button number " + i + j + " added");
plusX += 92.5;
}
plusY += 61.5;
plusX = 1;
}
}
我在主函數gridtest(),它的工作原理一個的addChild很好,但另一個在第二功能這裏(仍然是相同的文件):
static function NewUnit(locX, locY)
{
unit = new Unit(locX, locY);
unit.Set_ID(UnitList.length);
addChild(unit);
UnitList.push(Unit);
}
給我的錯誤1180:調用可能未定義的方法AddChild,它有什麼做的功能是靜態?或者完全是另一回事。