Posted By

cessnajumpin on 02/10/09


Tagged

String text as3 shorten ellipse


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

nreliu
zimmen


Simply Ellipse Long Strings


 / Published in: ActionScript 3
 

Extremely simple... just pass in the string you want to ellipse, and the position you want to do it at. The code takes care of the rest.

  1. private function ellipsed(fullString:String, cutOff:Number):String
  2. {
  3. if(fullString.length < cutOff)
  4. {
  5. return fullString;
  6. }
  7. else
  8. {
  9.  
  10. var ellipsedString:String = fullString.substr(0, (cutOff - 3));
  11. ellipsedString += "...";
  12. }
  13.  
  14. return ellipsedString;
  15. }

Report this snippet  

You need to login to post a comment.