Use Caution When Sending Boolean Values Via XML to E4X and Actionscript 3
Posted by Tres Thu, 19 Mar 2009 05:12:00 GMT
Okay, all hyperbole aside, passing boolean values via XML will cause problems if you’re not using integer values for your booleans. E4X will happily pass string values “true” and “false” to your function, which will always interpret the non zero value of the string to be true.
So, you’ve got two easy options: either convert the boolean to an integer server-side and cast it to a boolean in Actionscript, or handle it using string value comparisons in your Flash app.
I’m partial to trouncing as little as possible on the XML being generated server-side, so a little:
var localBool:Boolean = (xml.value == "true");
and we’re all done.