Flash AS3: crop TextField content off at X lines, add '...' at the end
- by matt lohkamp
There's only room for three lines of text in the interface, but the content is external and variable, and if it ends up taking up more than three lines, there needs to be some sort of 'view all' button functionality. I can kind of think about what that function needs to look like, but I'm not quite sure what the best way to do it in AS3 would be. Something like (in pseudo code):
function cropText(source:TextField, length:int, append:String):TextField{
if(source.lineCount > length){
source.text = // magic function that retuns the first length lines,
// minus append.length characters, with the append value tacked onto the end
}
return source;
}
... right? How would you fill in the missing bit?