-
Musical chair
[RESOLVED] Finding the size of a text box
So, I have a dynamic text box, which, naturally, being dynamic, changes.
What I would like to figure out is how to tell when the changing text is larger than the textbox holding it.
Of course, just because it is a certain number of characters long doesn't mean it will be larger than the textbox holding it. Twenty of the letter "w" is larger than twenty of the letter "i"
So, is there a way to tell if the textbox isn't large enough to hold its text?
Thanks
-
Make the text box a set size, assign the text to it, and check the maxscroll. If maxscroll equals one, the text fits in the textbox.
-
You could also try textWidth function.
if(textBox.textWidth > textBox._width){
trace("Text is wider than the holder");
}
Have never tested that function, but it should work.
-
Musical chair
Thanks, guys, for responding.
Sorry, I forgot to mention this is a multiline textbox.
For some reason, textBox.textWidth and textBox.textHeight (height being what I need) are undefined when I trace them.
And I would use maxscroll, but, with what I'm doing, my text's font will get smaller when the text doesn't fit in the textbox. So, maxscroll changes variably.
But, if I figure out how to make textHeight work, I think this will work.
Thanks again!
-
Musical chair
And, I also found out it's only undefined when I use actionscript to change what it says.
PHP Code:
textBox = "Hello."; //or textBox="HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello.";
Either one of these lines of code being put before the trace(textBox.textHeight); makes it undefined, which is weird.
Any idea why?
-
Musical chair
Okay, I figured it out. For some reason, you need to add ".text" to the end of the textbox's variable name.
PHP Code:
textBox.text = "Hello...";
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|