Reputation: 10072
when i recieve a boolean out of an array, it's always displayed as a string (true/false).
how can i reconvert it?
var _myNumber = 1;
var _myText = "HELLO WORLD!";
var _myArray:Array = new Array()
_myArray.push(Boolean(Number(_myNumber))+"::"+_myText)
//now split _myArray to get the inside data:
var _splitArray:Array = _myArray.split("::"),
trace(_splitArray[0]) // = true (but it's not a boolean value)
?
Upvotes: 0
Views: 1402
Reputation: 46027
When you are pushing the boolean in the array, you are converting this to a string by concating that with other strings. This will actually call toString() of Boolean. Now toString() of Boolean returns "true" or "false". You can convert that back to boolean by using this.
var b:Boolean = (_splitArray[0] == "true") ? true : false;
EDIT: As pointed in the comment, this is enough to write.
var b:Boolean = _splitArray[0] == "true";
Upvotes: 2