Why is this code throwing ReferenceError #1069?

739 views Asked by At

The first line of this code is throwing ReferenceError #1069. "Property focusMask not found on ObjectButtonSkin and there is no default value." The "skin" variable is of type MovieClip, and the actual object instance is of type ObjectButtonSkin (which extends MovieClip).

if (skin["focusMask"] != null)
    if (skin["focusMask"] is DisplayObject)
        (skin["focusMask"] as DisplayObject).visible = false;

This was never a problem before, so I'm not sure why this is happening. The ObjectButtonSkin class is not marked as dynamic or anything else, so perhaps that's the problem? One site suggested I should be using "()" instead of "[]" to access the property, but that doesn't seem right.

1

There are 1 answers

4
Roy On BEST ANSWER

A better check for the existence of focusMask would be:

if (skin.hasOwnProperty("focusMask") && skin.focusMask!=null)...

Or, if you want to be cleaner, you should extract the focusMask to a variable:

var focusMask:DisplayObject = skin.getChildByName("focusMask");
if (focusMask)
    focusMask.visible = false;