Just find out how many characters fit into your allocated textfield space
then count the characters coming in
You could put the string of text that you want in the textfield into an
array that is broken by each word like this..
//str being the string that u want to work with
_str_arr = str.split(" ");
Then character count each word till you reach the maximum your textfield
holds
//keeps track of how many characters
var char_cnt:int = 0;
//limit is how many characters your textfield can hold
var limit:int = 50;
//new string array
newString_arr = new Array();
for(var z:int = 0; z < _str_arr.length; z++){
//want to keep count of each word and break when the char_cnt
//hits the limit
char_cnt += _str_arr[z].length;
//if the character count is equal or greater than the limit *
the num of lines, store that info
//and break out of the for loop
if(char_cnt >= limit){
newString_arr = _str_arr[z]);
break;
}
}
Now u have a new array of words that fit into your textfield. Concat them
together into a new string and put it into the textfeld.
In your new array if the last word in the element doesn't include a period
then you need to add the "..."
Hope this helps
greg
On 11/17/08 4:26 AM, "Latcho" <[EMAIL PROTECTED]> wrote:
> How to break a line of text on the optimal charachter and adding "..."
> if it doesn't fit a single lined textfield
> | I would like to break | this line of text.
> | I would like to br... |
>
> Any suggestions (AS3)
>
> Latcho
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Gregory Boland | IconNicholson
Flash Engineer, Technology
[EMAIL PROTECTED]
tel +1 212.981.0563
mobile +1 201.600.6269
295 Lafayette Street, New York, NY 10012
www.iconnicholson.com
------------------------------------------------------
This communication may contain information that is confidential or exempt
from disclosure. If you are not the intended recipient, please note that
any dissemination, distribution, or copying of this communication is
strictly prohibited. Anyone who receives this message in error should notify
the sender immediately by telephone or by return email and delete it from
his or her computer.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders