tags:

views:

243

answers:

1

I have a sprite on which I have added two textfields
side by side, horizontally.

I have set the buttonmode of sprite = true.
But the mouse cursor changes from regular to
clickable only when I hover it on the textfields.

In the empty area between the two textfields,
the cursor still appears regular/normal.

Why could it be?

+1  A: 

The TextField instances are the only objects occupying space in the Sprite. Therefore, the hand cursor only appears when they are hovered. What you need to do is define the width and height of your Sprite to the maximum space occupied by your objects inside it (or greater than that, if you want), then apply buttonMode = true:

var mySprite:Sprite = new Sprite();
mySprite.addChild(textField1);
mySprite.addChild(textField2);
mySprite.width = textField1.width + textField2.width + Math.abs(mySprite.textField2.x - mySprite.textField1.x);
mySprite.height = (textField1.height > textField2.height) ? textField1.height : textField2.height;
mySprite.buttonMode = true;

If that doesn't work, you can check out the documentation:

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Sprite.html#buttonMode

bobthabuilda
1. Doesn't a Sprite adjust its width and height to fit its children?2. I had tried to set Sprite's width and height manually, for e.g. sprite.width = 248 and sprite.height = 50, but strangely it stretches the textfields on it.
dta