侦听启用/禁用状态更改

Cod*_*ius 3 apache-flex mxml actionscript-3

对于我的自定义组件,当它们从启用到禁用或禁用到启用时,我想触发自定义事件.我在找不到相关的事件.请问有什么线索吗?

Ama*_*osh 5

UIComponentenabledChanged从它的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"));
}
Run Code Online (Sandbox Code Playgroud)

您可以使用以下方式收听:

myComponent.addEventListener("enabledChanged", handleEnabledChanged);
Run Code Online (Sandbox Code Playgroud)