You'll need to add the Bindable metadata to both getDescription on Toy() as
well as CartItem() and within your CartItem class you need to listen for the
changed event within Toy and rebroadcast a new changed event from CartItem
when the contained Toy change it's description.
HTH,
Sam
public class Toy extends EventDispatcher {
[Bindable("descriptionChanged")]
public function getDescription():String {
return ""; // assume is overridden in child class, which also
broadcasts descriptionChanged
}
}
public class CartItem extends EventDispatcher {
private var _quantity:uint;
[Bindable("quantityChanged")]
public function get quantity():uint {
return _quantity;
}
public function set quantity(value:uint):void {
_quantity = value;
dispatchEvent(new Event("quantityChanged"));
dispatchEvent(new Event("descriptionChanged"));
}
private var _toy:Toy;
[Bindable("toyChanged")]
public function get toy():Toy {
return _toy;
}
public function set toy(value:Toy):void {
if (_toy) {
_toy.removeEventListener("descriptionChanged",
rebroadcastDescriptionChanged);
}
_toy = value;
if (value) {
value.addEventListener("descriptionChanged",
rebroadcastDescriptionChanged);
}
dispatchEvent(new Event("toyChanged"));
}
private function rebroadcastDescriptionChanged(event:Event):void {
dispatchEvent(new Event("descriptionChanged"));
}
[Bindable("descriptionChanged")]
private function getDescription():String {
return quantity + " " + toy.getDescription();
}
}
-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]