View Full Version : dynamic text
finster_baby
11-21-2002, 11:10 PM
I want to create a single line of dynamic text but, if there are more characters than space how do i get flash to cut off the feed and add "..." at a certain point?
sumul
11-22-2002, 04:51 AM
Are you using a fixed-width font?
finster_baby
11-22-2002, 11:45 PM
no. i'm relying on the users default font
CyanBlue
11-23-2002, 12:28 AM
While the user is typing or when the user is done typing and the focus is not on the input text field???
TextField.onChanged
In first case, you can check if the text field's content has been changed or not, and if it did check the length of the text field and cut if off at a certain specified point and add '...' at the end...
TextField.onKillFocus
The same thing goes to the next case, but use different handler to check the event...
BTW, I hope you don't get cursed by my 666th posting... :D
finster_baby
11-23-2002, 12:52 AM
user won't be inputing anything. It's more a banner that wil have text feed into it. So, if you are sitting at your computer all you'd see is a banner with a series of headline feeds about 50 characters long. I just need to figure out how to break the headline at the point that exceeds the 50 character point. The "..." will stand in for any text that goes beyond this point.
Once that is done, how do you get it to find the nearest space before the word that is getting cut off by the 50 charcter rule and have it place the "..." at that point so the word is not getting cut off at an arbitrary point?
CyanBlue
11-23-2002, 01:14 AM
Check out substr() and indexOf() functions to do the job...
sumul
11-23-2002, 03:38 AM
You have to keep in mind that if it's not a fixed-width font, you can't rely on the character count being a very good indication of the length of the text. For instance, fifty M's are a lot longer than fifty i's.
CyanBlue
11-23-2002, 04:01 AM
Ah... That's why you have asked that question... Good point... and goot teaching for me... :D
sumul
11-23-2002, 04:29 AM
A hack sort of way to do it is to put an image over the end of the text box. Make the image look exactly how the text box would look with '...' at the end of it.
Actually, this is a really bad way to do it, and I recommend that you figure out a more elegant solution. Bad things about this method: 1) the '...' will display even if the text is shorter than the text box, 2) the '...' image might cut off the text in the middle of a character (ugly!).
I'm ashamed I suggested this. Please find a better way. The only reason I'm not just abandoning this post is so that you have a last resort.
Sigh.
sumul
11-23-2002, 04:40 AM
Another thing you could try ...
Figure out how many of the widest character will fit in the text box (with a '...' after them). Then use the string functions (length and substr) to fill in the text box. For example:
if(headline.length < maxChars)
{
textvar = headline;
}
else
{
textvar = headline.substr(0,maxChars) + " ...";
}
Please excuse me if any of my function names are wrong, or if I've forgotten any basic actionscript constructs. I haven't actually written any actionscript in a couple of months :( because I've been too busy with school.
fileas
01-23-2003, 05:00 PM
what do you do if you want the headline to appear on two lines (if it's that long) and then have (...) at the end AND you don't want to split a word in two?
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.