Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Boolean in Actionscript for null

I have a Boolean variable in Actionscript 3.

How can I check if it's undefined (not by being false) because false is a value or Boolean in Actionscript is FALSE by default >

like image 747
Makky Avatar asked Jun 03 '11 11:06

Makky


2 Answers

If you want a Boolean that can be undefined (essentially a tri-state flag), you can use an Object reference, but just assign the Boolean values true and false to it. Downside is that you lose the type safety.

var isSet:Object = null;
// Later...
isSet = true;
like image 189
Ingo Karkat Avatar answered Oct 21 '22 04:10

Ingo Karkat


In ActionScript, Boolean can have either true or false value only. If you don't specify any value, it is initialized to false by default.

Edit: This behavior is different from Java's Boolean object type which is a wrapper over primitive boolean. See @Victor's comments below

like image 32
midhunhk Avatar answered Oct 21 '22 04:10

midhunhk