Sprite, buttonMode and nested TextFields

Posted: 31/12/07

An image of Sprite, buttonMode and nested TextFields

I've noticed a few problems getting Sprites to behave properly in buttonMode when a TextField is nested within. An example would be using the drawing API to create a basic button shape, then adding a TextField as a child to the Sprite to act as the label. Even with the buttonMode property of the parent Sprite set to "true" and the selectable property of the TextField set to "false", the hand cursor doesn't display properly. The answer is to set another property on the TextField to prevent it from soliciting any interactions with the mouse.

myTextField.mouseEnabled = false;

In all, your Sprite and nested TextField will need the following properties set:

this.buttonMode = true;

myTextField.selectable = false;

myTextField.mouseEnabled = false;

Keywords for this post: textfield, sprite, buttonMode, mouseEnabled, selectable, flash, actionscript 3