Posts Tagged ‘throw’

VerifyError: Error #1024: Stack underflow occurred.

Tuesday, July 31st, 2012

I just completed hunting down a Stack underflow error. It was a little tedious since the error is not thrown when I compiled for debug player, only release.
The source of it? A trace statement in a try block. For some reason the compiler doesn’t like that at all.

The solution seemed to be to remove all traces from try-catch blocks, which worked, but I wasn’t satisfied.

After binary searching trough the svn commits, I found what triggered the above error, an empty for-each loop.
Removing that loop made all traces work again normally inside try-catch blocks, which is what I prefer.

for each (var fruit:String in fruits) {
   // Empty loop, a BIG NO NO!
}

So to prevent your swf from corrupting, do not have empty for-each loops in your project! Remove them completely or fill them with some code.

Throwing an error in a constructor before the super() statement

Friday, April 13th, 2012

I would have thought you could throw an error whenever you pleased like it, however the Flex compiler has some other ideas.

If you have a throw statement before the super() in the constructor, Flex will complain with the following error code:
1201: A super statement cannot occur after a this, super, return, or throw statement.

There is a workaround though, just wrap the throw statement in an anonymous function:

(function():void {
	throw new Error("Yay for workarounds!");
})();