Changeset 4 for trunk/as3/com/jeroenwijering/utils/Strings.as
- Timestamp:
- 06/06/08 10:11:42 (18 months ago)
- Files:
-
- 1 modified
-
trunk/as3/com/jeroenwijering/utils/Strings.as (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/as3/com/jeroenwijering/utils/Strings.as
r1 r4 9 9 10 10 public class Strings { 11 12 13 /**14 * Fit string in a certain textbox, keeping full words.15 *16 * @param str The string to chop.17 * @param fld The textfield the string should fit into.18 **/19 public static function fit(str:String,fld:TextField):String {20 var wid = fld.width;21 var lns = Math.round(fld.height/18);22 var mxm = Math.round(wid*lns/6)-5;23 if(str.length < mxm || str.indexOf(" ",mxm) == -1) {24 return str;25 } else {26 return str.substr(0,str.indexOf(" ",mxm)) + ' ..';27 }28 };29 11 30 12
