by Jim
May 10, 2007 8:52 AM
I got the following error when running my flash program:
VerifyError: Error #1030: Stack depth is unbalanced. 2 != 0
The adobe documentation implies that the SWF file is corrupt; presumably this is due to a bug in the compiler, or a bug related to interpreting the compiled code.
I panicked for a second there - how do you work around a bug in the compiler? Wait for the next version? But I started playing with the code and found the source of the problem. Here's my function:
private function clickHandler(event:MouseEvent):void
{
// Is the click on the region of the main "button"?
if (SymbolMenuButton(getChildAt(0)).hitTestPoint(event.stageX, event.stageY))
{
showSubs(getChildAt(1).visible != true);
}
else if (mSymbols.visible && mSymbols.hitTestPoint(event.stageX, event.stageY))
{
// ToDo: Determine which symbol was clicked
dispatchEvent(new TextEvent(SYMBOL_CLICK, true, false,
mGlyphs[mSymbolsIndex, 1, 1]));
}
event.stopPropagation();
}
The exception was thrown in the first if block, not on the offending line, which is the dispatchEvent; specifically, the array access is causing the problem. If I change this to mGlyphs[mSymbolsIndex][1][1], then everything is fine.
It would appear that the compiler allows the incorrect array access, then the flash player gets confused by the compiled code and throws an error.