> how to cast String "true" to Boolean true ?
 
The expression s == "true" evalues to the Boolean value true if the String s is 
"true", and to false otherwise.
 
BTW, there is no point in writing 
 
    var btest:Boolean = new Boolean()
 
You should just write
 
    var btest:Boolean = false;
 
or
 
    var btest:Boolean;
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Luis 
Eduardo
Sent: Wednesday, April 18, 2007 4:54 PM
To: [email protected]
Subject: [flexcoders] boolean not casting ok from string




hi,

this simple code dont work.

var btest:Boolean = new Boolean();
btest = "true";
trace("btest = "+btest);

btest = "false";
trace("btest = : "+btest);

there are a compile warning telling me that: "3590: String used were a
Boolean value was expected. The expression will be type coerced to Boolean"
but it is not.

even if i do typecast it wont work:

btest = Boolean("true");
trace("btest = : "+btest);

or if i typecast with "as".
btest = ("true" as Boolean);
btest = ("false" as Boolean);

so i ask: how to cast String "true" to Boolean true ?
what am i missing???

Luís Eduardo.



 

Reply via email to