I was having a bit of difficulty making an xml node that had a value of true/false be cast properly as a Boolean. Turns out a good method is to when you are setting it, test it against a string value of true. The boolean will only be set to true if the string in your XML file is “true”.
1 2 | //Example var myBoolean:Boolean = XML.isTrueFalse == "true"; |
#1 by andy on June 5, 2010 - 3:41 am
i came across the same problem, and also found a string comparison to true to be the best way to fix it.
The reason is, assuming, like me, you were trying to cast the string as boolean something like
var myBoolean:Boolean = Boolean(XML.isTrueFalse);
will assign true if any string is present in that xml node.
#2 by Jeff on June 5, 2010 - 8:55 am
Nice tip, thanks!