Skip to main content
Inspiring
March 14, 2007
Question

does a variable exist?

  • March 14, 2007
  • 2 replies
  • 158 views
So... I've got an object, and I want to know if there is a variable inside the object named "thing"

like so:
objectInstance.thing

Is there a way I can test to see if "thing" exists? (regardless of thing's data type or content)

thanks
This topic has been closed for replies.

2 replies

Inspiring
March 14, 2007
objectInstance.thing == undefined ? trace ("objectInstance.thing is
undefined") : trace ("objectInstance.thing = "+objectInstance.thing);

Look out for line wrapping - the above is all one line. It's a shorthand way
of expressing:

if (objectInstance.thing == undefined){
trace ("objectInstance.thing is undefined);
} else{
trace ("objectInstance.thing = "+objectInstance.thing);
}



--
-------------------------------
Remove '_spamkiller_' to mail
-------------------------------


kglad
Community Expert
Community Expert
March 14, 2007
: