Listening to an on / off state change

For my custom components, when they go from enabled to disabled or disabled to enabled, I want to trigger a custom event. I can not find any related events in liveocs. Any clues please?

+3
source share
2 answers

UIComponentdispatches a type event enabledChangedfrom its method set enabled. Here is the source of this method:

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"));
}

You can listen to it using:

myComponent.addEventListener("enabledChanged", handleEnabledChanged);
+5
source

, , UIComponent ( ), Enabled setter, ?

- :

override public function set enabled(value:Boolean):void {
   super.enabled = value;
   dispatchEvent(new EnabledChangedEvent());
}
+1

Source: https://habr.com/ru/post/1724551/


All Articles