Ecmascript is just not Java. You can't overload operators and you're not doing true casting. Sorry, but you'll have to live with the suggestd code pattern.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Luis Eduardo Sent: Thursday, April 19, 2007 7:32 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] boolean not casting ok from string i see. So can i overload the "=" operator to it understand my needs? So i can do the converting transparently. btest:Boolean = "false"; i search on google and find it from a forum: "overloading is still not supported in AS3 (and that includes operators)" but dont know if its true. Alex Harui escreveu: > It is weird, but that what the ECMAScript committee decided. It is a > bit inconsistent, but you are actually calling functions and not > really casting. So you'll have to live with converting as to whether > the string == "true" > > ---------------------------------------------------------- > *From:* flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] > *On Behalf Of *Luis Eduardo > *Sent:* Wednesday, April 18, 2007 9:06 PM > *To:* flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > *Subject:* Re: [flexcoders] boolean not casting ok from string > > > > yeah shaun, you are rigth. After follow your sugestion i searched in > the docs and found what you mean here: > http://livedocs.adobe.com/flex/201/langref/package.html#Boolean > <http://livedocs.adobe.com/flex/201/langref/package.html#Boolean> > <http://livedocs.adobe.com/flex/201/langref/package.html#Boolean > <http://livedocs.adobe.com/flex/201/langref/package.html#Boolean> >() > Boolean its a function that have the same behavior than the Boolean > constructor that take a non-empty string and convert it to "true". > > aww. > > very weird. > > anyway thank you and the others to help understand what is going on here. > now i will try to minimize the damages :) > > []'s, > > Luís Eduardo. > > shaun escreveu: > > > 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 > > > > > >