Flex Sprite ButtonMode
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 开发者_如何学JAVAregular/normal.Why could it be?
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
精彩评论