Skip to content

Parse Boolean method for Flex

August 12, 2008

I wonder why there isn’t an out of the box Boolean parser in Flex, I must have built this same method at least 3 times for different projects… You should probably add this to your utils as well.

static public function parseBoolean(str:String):Boolean {
switch(str) {
case "1":
case "true":
case "yes":
return true;
case "0":
case "false":
case "no":
return false;
return Boolean(str);


From → Uncategorized

  1. anon permalink

    You might want to do a String.toLowerCase() before you start switching.

    Also, using enumerations will avoid a lot of headache whenever you’ve the luxury of being able to use them.

  2. Dan permalink

    It’s not rocket science but it saved me a few minutes of work.

    Cheers mate 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: