Hi,

Its not a bug. Note: the Constructor for Boolean in the docs.
Think about it as if you have the following:

var moo:String = "Moooooooooo";
if (moo) {
   // have a cow.
}else{
   //no cow.
}

So, Boolean("false") is true!

var y;
var x:Object;
var b:Boolean = Boolean("false");
trace("b1 false is "+b.valueOf());

b = 0;
trace("b2 (0) is "+b.valueOf());

b = 1;
trace("b3 (1) is "+b.valueOf());        

b = 2;
trace("b4 (2) is "+b.valueOf());        

b = -1;
trace("b5 (-1) is "+b.valueOf());       

b = null;
trace("b6 (explicit null) is "+b.valueOf());

b = x;
trace("b7 (unassigned null, undef) is "+b.valueOf());

b = y;
trace("b8 (undef) is "+b.valueOf());

b = (new Object() as Boolean);
trace("b9 (as not a boolean ie, null) is "+b.valueOf());


---------------------------------------------------------
b1 false is true
b2 (0) is false
b3 (1) is true
b4 (2) is true
b5 (-1) is true
b6 (explicit null) is false
b7 (unassigned null, undef) is false
b8 (undef) is false
b9 (as not a boolean ie, null) is false

--------------------------------------------------------


HTH,
  shaun

Reply via email to