AS3 - unbalanced stack?
I'm trying to create a boa开发者_运维技巧rd for a game, using a movie clip Block in my library. My code is in a linked actionscript file, and looks like this:
package {
import flash.display.*;
public class Plethora extends MovieClip {
public function Plethora(): void {
var m:uint=200;
var n:uint=200;
var boardArray:Array = [[0, 1, 0], [0, 1, 0], [1, 0, 1]];
for (var i:uint=0; i < 3; i++) {
for (var j:uint=0; j <3; j++) {
if (boardArray[i,j] == 1){
var thisBlock: Block = new Block();
thisBlock.stop();
thisBlock.x = m;
thisBlock.y = n;
addChild(thisBlock);
}
m = m -50;
}
n = n - 50;
}
}
}
}
When I test-run it, I get the following output:
verify Plethora$iinit() stack: scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ Plethora$] locals: Plethora * * * * * * 0:getlocal0 stack: Plethora scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ Plethora$] locals: Plethora * * * * * * 1:pushscope stack: scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ Plethora$] Plethora ... locals: Plethora? uint uint Array? uint uint Block 136:findpropstrict addChild stack: Array? Plethora scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$
I haven't the slightest idea what any of that could even begin to mean. I would appreciate some hints about how to start debugging this.
There may be something weird going on inside your Block MovieClip. Do you have any code in there? Also your 2D array syntax is incorrect:
boardArray[i, j]
Should be:
boardArray[i][j]
After making that change I copied your code on to wonderful and ran it - it seems to work fine. Have a look.
精彩评论