0
votes

Sorry for the bad title. Couldn't think of a better one...

I'm doing a software that is configurable with loaded data from XML. User can define the max "width" of an TextField and the TextFields are multiline and wrapping happens when the text wouldn't fit the width. Text for the TextFields is also loaded from the XML file and the length is arbitrary.

Because TextField doesn't have neither buttonMode or useHandCursor properties I made TextFields children of sprites. So for every TextField there is a sprite as a parent.

Then the real problem:

("TextFields" are actually the sprites with a TextField as a child)

The "TextFields" should not be clickable outside of the text in them. At the moment it seems like that the sprites extend to the full width of the TextFields and therefore user can actually click the "TextFields" from an area where there is no text.

I "tried" to change the size of the sprite, checked the AS3 reference and now I know why everything disappeared after that.

So I need a solution in which, the "TextFields" have buttomMode and useHandCursor enabled and the container should be able to cut off the area where there is no text.

2

2 Answers

1
votes

The TextField object has some default sizing characteristics. You need to apply one of these:

to this property:

to get it to form fit your text. Then by adding it into an empty Sprite, said Sprite will also be the exact size of your text.

Changing the size of the Sprite is the wrong approach as what you're actually doing in that case is scaling its interior content. Sprites automatically size themselves to fit the objects they contain. As long as you deal with making sure the TextField is sized properly, the parent Sprite will be sized properly as well.

0
votes

Im sure you dont need it anymore but someone may do, so here it is.

As you have a sprite as parent them you can make him to desable the mouseChildren.

yourSprite.tf.text = 'something';
yourSprite.buttonMode = true;
yourSprite.mouseChildren = false;