我想创建包含影片剪辑和文本字段的 3d 数组。这是我的代码:
public function init():void
{
//initalize the arrays
for (var _x:int = 0; _x <= MAX_X; _x++)
{
colArray = new Array();
for (var _y:int = 0; _y <= MAX_Y; _y++)
{
textArray = new Array();
for (var _z:int = 0; _z <= MAX_Z; _z++)
{
var txt:TextField = new TextField();
textArray.push(txt);
}
var mc:MovieClip = new MovieClip();
colArray.push(mc);
}
rowArray.push(colArray);
}
}
public function addBoxes(isUpdate:Boolean):void
{
for (var _y:int = 0; _y <= MAX_Y; _y++)
{
for (var _x:int = 0; _x <= MAX_X; _x++)
{
for (var _z:int = 0; _z <= MAX_Z; _z++)
{
// Create captions
var mcCaption:MovieClip = createMc("captionBox", false);
spSource.addChild(mcCaption);
mcCaption.addEventListener(MouseEvent.MOUSE_DOWN, mcCaptionHandler);
colArray[_x][_y][_z] = mcCaption;
mcCaption.x = nextXpos;
mcCaption.name = "beatCaption_" + _y;
// trace(colArray[_x][_y][_z]);
}
}
}
...
}
我想在我的电影剪辑上添加一些文字。我怎样才能做到这一点?我的代码给了我错误:TypeError: Error #1010: A term is undefined and has no properties.
这个说法有错吗?
colArray[_x][_y][_z] = mcCaption; // mcCaption is a movieclip