/ Published in: ActionScript 3
function to replace any capital letters with Large letters and make everything capitalized
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static function initialize(t:TextField, normSize:int = 12, largeSize:int = 17, auto_size:Boolean = true):void { var upArray:Array = new Array(); var firstCharFormat:TextFormat = new TextFormat(); firstCharFormat.size = largeSize; var normalFormat:TextFormat = new TextFormat(); normalFormat.size = normSize; if(auto_size){ t.autoSize = TextFieldAutoSize.LEFT; } var str:String = t.text; var length:Number = t.text.length; for (var j:int = 0; j < length; j++) { if (str.charCodeAt(j) > 64 && str.charCodeAt(j) < 91) { upArray.push(true); }else { upArray.push(false); } } t.text = t.text.toUpperCase(); for (var i:int=0; i < length; i++) { if (upArray[i] || str.charAt(i) == " ") { t.setTextFormat(firstCharFormat, i); }else { t.setTextFormat(normalFormat, i); } } }