Actionscript: undefined public variables?
2 answers
Make the property myVar a and use another variable to check if it's not explicitly set.
public class Doc
{
public function Doc():void {}
private var _myVar:Boolean;
private var myVarSetExplicitly:Boolean = false;
public function get myVar():Boolean
{
return _myVar;
}
public function set myVar(value:Boolean):void
{
myVarSetExplicitly = true;
_myVar = value;
}
}
+5
source to share
You cannot use boolean, it defaults to false and false === false.
You could not strictly inject a variable and then use a getter and setter for type protection
public class Doc {
private var _myVar;
public function set myVar(value:Boolean){
_myVar = value;
}
public function get myVar(){
return _myVar;
}
}
Now that its not set myVar should be === null and you can only then set it to boolean.
But it feels a little hacky and I'm wondering why you need to tell the difference.
0
source to share