Question

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.

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top