Skip navigation.
Home

Sprite dimensions gotcha

While developing the homepage animation for portfolio.baizman.net, I tried to create a Sprite and then add a text field to that Sprite. When I specified the width and height of the Sprite, I noticed that nothing appeared on the screen, and that neither the compiler nor the output panel displayed any errors. What's the deal?

It turns out that a Sprite cannot be assigned a width and height--and trying to do so will cause it to silently fail. Check out the official documentation:

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#width

"Except for TextField and Video objects, a display object with no content (such as an empty sprite) has a width of 0, even if you try to set width to a different value."

This should at least fail with a runtime warning or error in the output panel.

In the documentation, the width and height properties are confusingly labeled as read-write, though they are only writable in certain circumstances. Adobe, please fix this!

see more related to: