VerifyError: Error #1024: Stack underflow occurred

Wow – I’d never seen this one before. So I’m putting up here to remind me what to look for if I ever see it again!

Basically I had a SWF that ran fine in debug build mode in FlashDevelop but if I set it to compile as a release version this error soon appeared.
On closer inspection it turns out that in the line that was crashing (which was hard to find in itself) I was using a variable named “h” in a loop. The clue was that this var h:DisplayObject was coloured green by the compiler and therfore most likely an internal variable in a parent class. All I did was change it for something a bit more descriptive and unique and it all compiled. So lessons learnt – listen to the code highlighting hints and don’t be lazy and use short variable names!

Phew.

A bit of searching also suggested that it may be a Flex 4.1 SDK related bug as I would have assumed that the compiler would give you a warning even when compiling a debug version. If anyone can shine any more light on this one please post.

William Hill Careers Papervision

Baldscone was involved in coding the 3D Flash component of this website. Making extensive use of Papervision 3D and XML to create a custom coded navigate-able panorama, it allows the user to navigate the 3D betting room. Content is all provided dynamically along with jobs ticker. Video, images and text are used in textures and are updated via XML. Hotspots are created using an authoring tool for generating 3D areas and coordinates.

Visit it at: http://careers.williamhillplc.com/

Tinting the colour of a MovieClip

Here’s an old snippet that I use quite often to set the tint of a MovieClip. It’s useful if you put all of these sorts of utilities in a class and access them via public static methods. So in a utility class called MovieClipUtils.as you could call:
MovieClipUtils.tint(myMovieClip, 0xff0000, 0.5);

[code]
//Color an MC with option amount  (0-1)
public static function tint(target:MovieClip, color:Number, amount:Number = 1):void
{
//create a new Color object
var c:Color=new Color();
//set the color of the tint and set the multiplier
c.setTint(color, amount);
//apply the tint to the colorTransform property of the desired MovieClip/DisplayObject
target.transform.colorTransform = c; //mc is a MovieClip
}
[/code]

Common XML character codes

Sometime when using XML data in Flash/FLex you need to use special characters to save your XML breaking and I always forget what they are! So to save me a google search or two here they are again:

//XML character codes

& Ampersand &
> greater-than >
< less-than &lt;
‘ apostrophe &apos;
“ quote &quot;