How do I test if a property exists on a object before reading its value?
- by Jeremy Rudd
I'm attempting to read a property on a series of Sprites. This property may or may not be present on these objects, and may not even be declared, worse than being null.
My code is:
if (child["readable"] == true){
// this Sprite is activated for reading
}
And so Flash shows me:
Error #1069: Property selectable not found on flash.display.Sprite and there is no default value.
Is there a way to test if a property exists before reading its value?
Something like:
if (child.isProperty("readable") && child["readable"] == true){
// this Sprite is activated for reading
}