I have a dynamic alert method that pops up an alert movieclip which tells the user that their search was not successful.
alert("Map [" + inputTxt + "] not found.");
Now, I would like to do something along the lines of
if (alertText.textWidth > myText.text.width) {
myText.text = "Map not found.";
}
What this is supposed to do is not show the inputTxt variable if the total text in the textbox exceeds the textbox itself in size.
That which I have does not work. I am open to any suggestions (as long as they remain short and concise).
FURTHER INFORMATION:
alertText is the string fed into the object. myText.text is a textbox.
I want to check if alertText will fit in myText.text BEFORE putting it in the textbox.
-Olin
a string does not have a textWidth property. There is no (easy) way to know ahead of time if your text will fit, unless your using a font where every char is the same width.
Here is a way to accomplish this:
This assumes your not using the
autoSizeproperty of the textField and are explicitly settings the width/height.