对于我的自定义组件,当它们从启用变为禁用或从禁用变为启用时,我想触发一个定制事件。
我在livedocs中找不到任何相关事件。
有什么线索吗?
最佳答案
UIComponent
确实从enabledChanged
方法中调度了set enabled
类型的事件。这是该方法的来源:
public function set enabled(value:Boolean):void
{
_enabled = value;
// Need to flush the cached TextFormat
// so it recalcs with the disabled color,
cachedTextFormat = null;
invalidateDisplayList();
dispatchEvent(new Event("enabledChanged"));
}
您可以使用以下方法收听:
myComponent.addEventListener("enabledChanged", handleEnabledChanged);