While not precisely intuitive, that is expected behavior.  I looked for
a technical explanation but didn't find one immediately.  As I recall,
it is because the argument to the Boolean() cast is an object, and an
object containing a string is always true.  It would be false if the
object were null.

 

Use this instead: (myString == "true")

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Marvin Froeder
Sent: Monday, February 04, 2008 3:01 PM
To: [email protected]
Subject: [flexcoders] Strange behavior....

 

I'm making some test with Boolean Flex cast.


See:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
    initialize="main()"
    >
    <mx:Script>
        <![CDATA[
            private function main():void {
                trace("Boolean: " + Boolean("true"));
                trace("Boolean: " + Boolean("false"));
            }
        ]]>
    </mx:Script>    
</mx:Application>


I expect true and false on console.

But I got:
[SWF] C:\framework\workspace\CobaiaFlex\bin\BooleanTest.swf - 445.501
bytes after decompression
Boolean: true
Boolean: true


What happened?


Marvin

 

Reply via email to