You can check txt_tf.textWidth before and after adding a character to
the textfield, if it doesn't change, the character is not embedded.
Something like this:
//Your textfield in stage with some characters embedded
var tf:TextField;
//The characters you want to test
var chars:String = "abcdefghijklmnopqrstuvwxyz123";
for (var i:Number=0; i<chars.length; i++) {
var previousWidth:Number = tf.textWidth;
tf.text += chars.charAt(i);
if (tf.textWidth==previousWidth) trace(chars.charAt(i) + " is not
embedded");
}
Ellen Sundh escribió:
Hi!
I wonder if there is a way to count characters visible in a textfield?
I have a text where not all characters are embeded in the textfield
and I want to check how many that are.. So it would be great if there
was I way to check the length of the text in the textfield and not the
original string.
I use this code, but it returns the same number of characters even
though the textfield displays less characters.
latin1 = "ÀÁÂÃÄÅ..";
trace("latin1 " + latin1.length);
txt_tf.text = latin1;
trace("txt_tf.text " + txt_tf.text.length);
Thanks in advance!
Ellen
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com