Custom Boolean wrapper in Actionscript
I'm in the process of writing a Java Boolean equivalent in Actionscript since Actionscript Boolean does not support nul开发者_开发问答l
so I have to write my custom boolean.
Does any have any idea how can I do this ?
In order to make a custom boolean class, you will need to start by constructing that class.
Here is a link to an Adobe article giving a brief intro on classes.
You will probably want lots of functionality in this class, similar to Java, so look through this page to see exactly what the Java Boolean class can do.
I am unsure if ActionScript has anything similar to the Comparable interface that Java Provides, so your conditional statements may require a method call to the Boolean object to return the primitive data, i.e.:
if(myBooleanObject.getValue()){
doSomeCode();
}
I hope this helps, as you question was slightly vague.
It isn't your best option to create a custom class which extends boolean. Actually, I'm not certain of a circumstance where it is a good idea to extend any primitive, at least in AS.
You're far better off having some other value -- if needs be use one of the number variants and have it set to NaN off the bat. Better yet, use int and a > < = comparator. Even better still, use constants and compare based off of those.
精彩评论