The problem i have is that i am pulling in some text dynamically through a large xml file, the text isn’t uniformed in the xml file though with some of it all in capitals while others are all lowercase. Is there a way to set all of them to one or the other when displayed in a textbox?
Hello Friend,
Yeah sure… you able to convert all letters in to single case… Follow the below code…
if you need all letters in capital… First you need to save all data in to one string… like the following…
var str:String = “Hello Friend”;
str.toLowerCase(); // hello friend;
str.toUpperCase(); // HELLO FRIEND;
Regards,
vamsi.g
thanks do you by chance though know how to make the first letter in each word be capitilized and the rest in lower case?
function formatSentence(sentence:String):String
{
var words:Array = sentence.split(" “);
for (var i:Number = 0; i < words.length; i++)
{
words* = formatCase(words*);
}
return words.join(” ");
}
trace(formatSentence(“is THIs ForMATTed COrreCTLY?”));
Thanks for that but i couldn’t get it to work for me. I have been playing and have come up with a solution for my problem, I know it’s not perfect and only works for 2 names but here it is.
var cut:Array = curr_node.split (" ");
cuts = cut[0].substring(1,0).toUpperCase()+cut[0].substring(1).toLowerCase()+ " " +cut[1].substring(1,0).toUpperCase()+cut[1].substring(1).toLowerCase();
if(cut.length==1){
cuts = cut[0].substring(1,0).toUpperCase()+cut[0].substring(1).toLowerCase();
}
If anyone knows a better way please let me know.