So, Flash, why do i bother declaring variables? Friday evening, 22 October 2004
I've been increasingly annoyed lately with ActionScript 2.0's treatment of declared variables.
I've lately been writing a small class to load application variables from an XML file straight into a class (i.e. a classes instance properties) but I've been confounded in trying to detect if each variable exists or not.
Try out the following example.
var something:String;
if(something == undefined){
trace("something is undefined");
}
if(something == null){
trace("something is null");
}
trace("something is really "+something);
trace("and something is a "+typeof something);
something is clearly defined but flash doesn't think it is. If you set
something to
null then flash still thinks that it's undefined.
The same affects the type. Even when you declare the variable type,
String in this example, flash can't pick that up until you put a value inside it.
The only solution, for me, is to give everything that's going to be over written with the values from the XML file a blank value.
Comments
Get Around
Journal
- contemplating.Thoughts from a Christian world-view.
- enjoying.Reviews of stuff i've been enjoying.
- life.For those that would like to know what i'm up to, this is the place to look.
- working.Thoughts and ideas on web development and projects i'm working on.