I'm reposting this from late Friday afternoon, hope that's OK. I found a thread where something similar, and having to do with Cairngorm, was described as 'deep' data binding. I'd appreciate any help
--- In [email protected], "Brian" <[EMAIL PROTECTED]> wrote: > > I'm trying to bind a Text control to a function to get the description > of an item, when a property of a class inside that item changes. Is > this at all possible? I've tried different variations of binding > functions, Binding tags, etc. and still can't get it to work. Here are > code snippets that will hopefully explain what I'm trying to do. > > package src > { > [Bindable] > public class Toy > { > public getDescription():String { > // will be overridden in subclasses > return ""; > } > } > } > > package src > { > [Bindable] > public class ToyTruck extends Toy > { > public var color:String; > > public override function getDescription():String { > return color + " truck"; > } > } > } > > package cart > { > import src.*; > [Bindable] > public class CartItem > { > public var quantity:int > public var toy:Toy; > > public function getDescription():String { > return quantity + " " + toy.getDescription(); > } > } > } > > MXML component > <mx:VBox> > <mx:Script> > <![CDATA[ > import cart.CartItem; > import src.*; > > [Bindable] > public var _cartItem; > > public function getText(toy:Toy):String { > return _packItem.getDescription(); > } > ]]> > </mx:Script> > <mx:Text id="itemDesc" text="{getText(_cartItem.toy)}"/> > </mx:Vbox> > > What I'd like to have happen is have the Text control update when the > ToyTruck.color is changed by other events. Is this possible? The above > code snippets is what I'm currently trying but the Tex is not > updating. Even though the toy is not used directly in the getText() > function, I thought having it as a parameter was how the function was > triggered. The docs say that when a bindable property as an argument > of the function changes, the function executes. > > In reality, there are different properties for different subclasses of > Toy, which could be modified by several different events. This is why > I'm trying to get the binding to work, so I don't have to manually > update the Text control all over the place. I thought that was the > whole point of Binding, but maybe I'm missing something. > > Or do I have to use a Binding tab for each of those different > properties of the subclasses? I haven't tried that yet but I don't > think that would work because the source has to be a string, right? > > Thanks >

