Oh sorry, I omitted the the getter from my example - but yes, I have getters. (The IDE warns you that [Bindable] doesn't do anything when you omit the getter.)
I'm wondering if data binding requires the event to be a PropertyChangeEvent for data binding to work? Michael On Mon, Nov 24, 2008 at 11:12 PM, Amy <[EMAIL PROTECTED]> wrote: > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, > "Michael Prescott" > <[EMAIL PROTECTED]> wrote: > > > > I'm having some troubles with data binding and a named event > generated > > by a custom non-visual component. What I'm trying to do is have a > > property (say, 'data') which, when it changes, triggers the usual > > data-binding updates, but also fires an event that can be listened > to > > in the MXML. For example: > > > > <foo:MyClass id="thingy" dataChanged="Alert.show('hi mom');"/> > > <mx:Label text={thingy.data}"/> > > > > I can't seem to meet both of these requirements without throwing two > > separate events. Is this what I should expect? > > > > When I do this: > > > > [Event(name="dataChanged")] > > public class MyClass { > > > > [Bindable(name="dataChanged")] > > public function set data(data:Object):void { > > this._data = data; > > dispatchEvent( new Event("dataChanged") ); > > > > ..then the data binding doesn't work. (The label text doesn't get > > updated.) It seems I have to resort to vanilla data binding (with > no > > event name), and in addition throw a 'dataChanged' event of my own. > > > > [Event(name="dataChanged")] > > public class MyClass { > > > > [Bindable] > > public function set data(data:Object):void { > > this._data = data; > > dispatchEvent( new Event("dataChanged") ); > > > > Am I missing something? > > When Flex comes back to look at your data because you fired the > event, it can't get it because you made it write only by only > providing a setter and not a getter. > > HTH; > > Amy > > >