Return to Snippet

Revision: 16310
at July 30, 2009 17:59 by sweetbabyyoung


Initial Code
//Recieves a string, checks to see if it is true/false, passes boolean back
function checkBoolean(val:String):Boolean {
	if (val.toLowerCase() == "true") { 
		return true; 
	} else { 
		return false; 
	}
}

Initial URL

                                

Initial Description
When receiving data that contains booleans from JSON, MXML and perhaps even XML, Flash thinks the boolean is a string. If you check to see if the boolean is true, it will always be true unless the value you are checking is null or blank. I created a function that checks to see if a string is true/false.

Initial Title
AS3 - Check to see if a string is true /false

Initial Tags

                                

Initial Language
ActionScript 3