Return to Snippet

Revision: 18085
at September 22, 2009 14:57 by gluecat


Initial Code
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);
				}
		    }
		}

Initial URL


Initial Description
function to replace any capital letters with Large letters and make everything capitalized

Initial Title
As3 Initial Caps

Initial Tags


Initial Language
ActionScript 3