I inherited a custom component from TextField. The component needs to know when any of its styles got changed at runtime via setStyle. How would I do that? It's probably obvious but I couldn't find an event or appropriate method to override.
If you want the text field to play nicely with containers and other components in Flex you may want to wrap it in a UIComponent
, or have the subclass implement the IUIComponent
and IStyleClient
or ISimpleStyleClient
interfaces (which UIComponent implements). If you do the component will work with Flex' style system and every time a style changes a method called
styleChanged` will be called:
public function styleChanged(styleProp:String):void
See http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#styleChanged()
Hello
styleChanged () method
public function styleChanged(styleProp:String):void
Detects changes to style properties. When any style property is set, Flex calls the styleChanged() method, passing to it the name of the style being set.
This is an advanced method that you might override when creating a subclass of UIComponent. When you create a custom component, you can override the styleChanged() method to check the style name passed to it, and handle the change accordingly. This lets you override the default behavior of an existing style, or add your own custom style properties.
If you handle the style property, your override of the styleChanged() method should call the invalidateDisplayList() method to cause Flex to execute the component's updateDisplayList() method at the next screen update.
Parameters styleProp:String — The name of the style property, or null if all styles for this component have changed.
Adrian, http://www.timeister.com