Simply Ellipse Long Strings


/ Published in: ActionScript 3
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.