Search code examples
actionscript-3flex4

which way is good to check the object variable holding boolean value in as3?


        var myString:Object = "true";
        if (myString.toLowerCase() == "true")

or

        if (myString is Boolean)

or

        if (myString == Boolean)

Which one is good to check the object variable is holding boolean values (true or false). Or which one is right?

Thanks...


Solution

  • The short answer is :

    the first instruction : if (myString.toLowerCase() == "true").


    The long answer is :

    still the first instruction : if (myString.toLowerCase() == "true").

    because you are really checking if your string is equals to "true", while in the 2nd instruction you are checking if your string is a Boolean, and in the 3rd one your checking if your string is the Boolean class.

    Hope that can help.