Hello,
There are several ways to achieve your objective. One solution: override the data setter, and execute your logic that adjusts the appearance:
override public function set data(value:Object):void {
super.data = value;
updateUI(value);
}
private function updateUI(value:Object):void {
color = ...;
myLabel.text = ...;
}
If you also want to listen to properties (e.g. binding), you might want to do the following:
override public function set data(value:Object):void {
if (data != null)
model.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, myHandler);
super.data = value;
var model:Task = Task(value);
model.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, myHandler);
updateUI(value);
}
private function myHandler(event:PropertyChangeEvent):void {
if (event.property == "name")
updateUI(data);
}
private function updateUI(value:Object):void {
color = ...;
myLabel.text = ...;
}
Best regards,
Gabriela.