Uppercase text in Actionscript
Need to convert text to uppercase in ActionScript? The toUpperCase() method on the String class does exactly that. This works in both ActionScript 2 and ActionScript 3.
var lowerCase:String = "sample text";
var upperCase:String = lowerCase.toUpperCase();
// SAMPLE TEXT
The method returns a new string — it doesn’t modify the original, so make sure you assign the result to a variable or use it directly.
If you only need the first character uppercased (title case for a single word), you can combine charAt(), toUpperCase(), and substring():
var text:String = "hello";
var result:String = text.charAt(0).toUpperCase() + text.substring(1);
// Hello
For lowercase conversion, use toLowerCase() in the same way. These string methods follow the same conventions as JavaScript, so if you’re familiar with JS string handling, you’ll feel right at home. Both methods are locale-independent, so they work the same regardless of the user’s system language settings.