For my custom components, when they go from enabled to disabled or disabled to enabled, I want to trigger a custom event. I can't find any related events in the livedocs. Any clues please?
+1
A:
If they're custom components, and I'm assuming you're extending UIComponent (or a child class), why don't you just override the Enabled setter method, then dispatch a custom event within that?
Something like:
override public function set enabled(value:Boolean):void {
super.enabled = value;
dispatchEvent(new EnabledChangedEvent());
}
Marcus
2009-12-02 22:06:18
+1
A:
UIComponent
does dispatch an event of type enabledChanged
from its set enabled
method. Here is the source of that 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);
Amarghosh
2009-12-03 04:29:17