Groups | Blog | Home
all groups > flash actionscript > august 2004 >

flash actionscript : Wrong value for textfield._height on wrapped text?


Peter Weidauer
8/28/2004 6:47:32 PM
Hi,

I get this strange behaviour then creating text fields via Actionscript
in Flash 6:

this.createTextField("field", 0, 0, 0, 100, 1);
field.autoSize = field.wordWrap = true;
field.text = "Something long enough to be wrapped";

trace(field._height); // outputs 16
trace(field._height); // outputs 40
trace(field._height); // outputs 40

Looks like the first call to _height wrongly gives the value for a
unwrapped field. This call however somehow 'updates' the fields _height
since consequent calls return the correct value.


The same happens when asking for another property first:

trace(field._x); // outputs 0
trace(field._height); // outputs 40
trace(field._height); // outputs 40


Now, am I missing something here? Am I doing something wrong or is this a bug?

Thanks,
Peter
kglad
8/28/2004 11:52:32 PM
what bug? 1/1000 second to figure out that flash can't even start to allocate
textfield space for your text until it increases that textfield's height
doesn't seem like a bug. give your textfield enough height to display one
character and it won't even take that long.
Peter Weidauer
8/29/2004 3:42:30 AM
On 2004-08-29 01:52:32 +0200, "kglad" <webforumsuser@macromedia.com> said:

[quoted text, click to view]

I'm positioning textfields with content loaded from an external source
one below the other so I need that value instantly. I could have given
the field a height of 20. But since I have very different text sizes
this may sometimes be too much and sometimes be too little space.

I ended up doing a dummy request for another property before asking for
_height:

this.createTextField("field", 0, 0, 0, 100, 1);
field.text = "whatever wrapped text goes here";
var dummy = field._x;
var fieldHeight = field._height;

Take out the dummy thing and you get the wrong height.


But I did increase the height parameter for createTextField() and I get
wrong _height values for sizes 1, 2 and 3. For 4 pixels and above the
value is correct. This minimum value seems to be independent of the
text size used in the field, so you are right, it's the better
solution. Still kind of strange...
AddThis Social Bookmark Button