English 中文(简体)
2D Array 电影剪辑
原标题:2D Array of Movie Clips - Error #1006

我仍在学会用AS3号法规,这似乎很直截了当,类似于Java,因此,如果我where误了某些地方的话,我会抱歉。

根据问题标题,我正试图制作一个2D(封顶)系列的电影剪辑,我已经制作,以便按以下方式印制。

var NumCols:Number = 8;
var NumRows:Number = 8;
var ColWidth:Number =  (stage.stageWidth-8)/NumCols;
var ColHeight:Number = (stage.stageWidth-8)/NumRows;
var GemMatrix:Array = new Array( 8, 8 );
var n = 1;
var SW:Number = stage.stageWidth;
var SH:Number = stage.stageHeight;

private function GJ_GenerateBoard(event:MouseEvent):void {
// Initialization...
for (var j = 0; j < NumRows; ++j)
{
    GemMatrix[y] = [];
    for (var i = 0; i < NumCols; ++i)
    {
        trace(i,j);
        GemMatrix[i][j] = new Gem() as MovieClip;
        this.addChild(GemMatrix[i][j]);
        GemMatrix[i][j].x = i*ColWidth+ColWidth/2;
        GemMatrix[i][j].y = j*ColHeight+ColHeight/2;
    }
}

我收到的错误是:

ReferenceError: Error #1056: Cannot create property 0 on Number.

在我试图创建新的Gem(Gem()案时,情况就是如此。

Any help is greatly appreciated. Thanks!

最佳回答

var Gemrix:Array = 新的Array(8,8)

这就是你所言。 这实际上创造了1D阵列,即[Number(8),第(8)号]。 你们不需要界定SAP3中阵列的长度,这里我是如何确定:

var GemMatrix:Array = [];

for (var i:int = 0; i < NumCols; i++){
    var $a:Array = [];
    for (var m:int = 0; m < NumRows; m++){
        var $gem:MovieClip = new Gem();
        $gem.x = i*ColWidth+ColWidth/2;
        $gem.y = j*ColHeight+ColHeight/2;
        addChild($gem);

        $a.push($gem);
    }
    GemMatrix.push($a);
}

而且,这一行程很奇怪:GemMatrix[y] = []; 造成错误的唯一原因,是,从现在的那类人中,自然是一种动态财产,表明其地位(很可能是这种性质=0)。

问题回答

暂无回答




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

Red5 Security Tutorial

I am looking for a step by step tutorial on securing Red5 from intrusion. This seems to be a question that comes up alot in a google search, but is never really answered in a way that makes sense to ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

visible property of DisplayObject

For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set mc1.visible = false; mc2.visible stays true. Is that supposed to happen?...

热门标签