Currently @
Home>/blog.html>Code is poetry>Flex: Capitalize First Character of a String – CamelCase Function in Flex
About Manoj Sachwani
Manoj Sachwani runs ManojSachwani.com, publishes content for the blog here at ManojSachwani.com (formerly: indefiniteloop.com/blog/), sends out a couple of newsletters, does a couple of podcasts, tries to mentor and teach developers, provides services that aim to help startups & founders, along with running a shop over at OddCuriosity.com.
Formerly known as 'the indefiniteloop blog', the blog here is a continuation of the topics, categories and content that Manoj Sachwani has been writing and publishing online since 2007.
Manoj Sachwani helps startups, solopreneurs, managers, designers, ceos, entrepreneurs, founders, artists, and creators like you to achieve their goals, build processes, validate ideas, and improve business models. He is a startup and small business consultant from India, with 20+ years of experience.
The shop over at @ OddCuriosity™.com sells custom made, one of a kind, limited editions of apparels, home furnishings and accessories that are made of curiosity. The products are designed and sold under the brand of Odd Curiosity™ by Manoj Sachwani and Appathethic Studios.
Subscribe to the eccentric, irratic Indefiniteloop newslettter series. I hate spam as much as you do. I, also, value your privacy as much as I do mine. So, rest assured that you will only gain valuable content from subscribing here!
Listen to the 1x1 Show — a solo podcast that goes over topics like freelancing, full-stack development, designing, content creation, psychology, philosophy, art, and others.
People Talk Series is a podcast where Manoj Sachwani talks to people from all walks of life. Listen in to candid conversations with people who inspire, evoke curiosity, and make you take action.
I was writing an Air App in Flex 3 and Action Script 3 and came across a situation where I needed to covert some strings to camel case dynamically before binding them to a control, I searched the API for any such function that would let me convert a string to camel case.
On not finding anything, I decided to write my own. Hope this helps some one.
PS: I might have used more variables than required.
//below is the function to create camelString
//needs little cleaning up.
privatefunctioncamelCaseString(inputstr:String):String{varloopcount:int;varreturnstr:String="";varorigStr:String;loopcount=inputstr.length;origStr=inputstr;while(loopcount>0){varlastSpaceIndex:int=origStr.indexOf(" ",0);if(lastSpaceIndex<0){lastSpaceIndex=origStr.length;}vartempstr:String=origStr.substring(0,lastSpaceIndex);varfirstpartStr:String=tempstr.substr(0,1);varsecondpartStr:String=tempstr.substr(1,tempstr.length);returnstr=returnstr+firstpartStr.toUpperCase()+secondpartStr.toLowerCase()+" ";origStr=origStr.substring(lastSpaceIndex+1,origStr.length);loopcount=loopcount-1;}returnreturnstr;}
Manoj Sachwani is a freelancer, full-stack developer, designer and creator with over 20+ years of experience. He likes writing poetry, code, haiku, and articles here on this blog.