Maybe the following will help.

Data Binding is really just a short hand version of an event broadcast, and 
listener and function to be executed.

Take the example:

[Bindable]
private var lastname:String;

<mx:Text text="{lastname}/>

<mx:Button click="lastname='My last Name'"/>

--
When the button is click the variable lastname value is updated to 'my last 
name'.

Since lastname is Bindable, it dispatches an event (broadcaster) that the value 
has changed. Any control listening to the change event, receives the event and 
runs a function to updates the property text to the new value. This of course, 
invalidates the display which then the display gets updated. 

The Bindable metatag creates a dispatch "change" event  (Broadcaster)

The {lastname} creates a listener for the text control to listen to the 
lastname "change" event 

A function is created that updates the property, text in this case, to the new 
value of last name.

I am sure it is more complicated than this (A function can also be Bindable, 
how does the function know when it changes value?). 

You can implement data binding using the event model.  It might be a good 
exercise, but you would not want to do it this way in an application. 

I know the above helped me greatly in understanding the events model. I hope it 
helps.

To answer your question 
But what about the times, where I won't know for sure beforehand, which 
component I will be using at the time?  

Using the above data binding example, data binding has no knowledge of what 
component will be using data binding. Data binding can be used on just about 
any component property. Again, data binding is a short hand of an event model 
and each component doesn't care what component will be used. 


The event model loosely couples the components, but both components must know 
about the event model.  Any component that creates an event listener and the 
function that should be executed when that event is triggered. The component 
must know about the event structure. The component that dispatches the event 
must also know the event structure. The event becomes an API, so to speak. Any 
component can listen or dispatch to that api. In other words, the event itself 
is communication between the two components and both components must know how 
to speak and listen to the event.


---


On Fri, 12 Jan 2007 12:53:14 -0600, Mike Anderson wrote:
> Hello All,
>
> This thread, directly relates to all the other ones I've posted recently
> - as I think one of my root problems, is truly understanding on how
> Events get propagated within an application.
>
> They say the Event model is so great, due to all the components being so
> loosely coupled.  So either I am missing something really rudimentary
> here, or the Event model doesn't work the way I thought it did.
>
> In every example I've seen, for an Event Listener and Broadcaster setup
> to work properly, there must be a common link (like a container) between
> the 2 components - and then, there are the 3 key things which must be in
> place: The Event Listener, the Broadcaster, and the Function that gets
> run whenever the Event gets triggered.
>
> But what about the times, where I won't know for sure beforehand, which
> component I will be using at the time?  Especially in a Cairngorm
> Application, where the Commands (which is where I desperately need to
> broadcast my Custom Events from) literally NEVER know where their Result
> Events are going to be sent.  Of course, this is where the true power of
> Cairngorm-based Applications comes into play.
>
> All the Commands do really, is update the ModelLocater with their
> updated results - and because of Data Binding, the Components in the
> Application show the updated results.  For me unfortunately, there is
> always much more that needs to be done, after a Result is brought back -
> and I need to find a way to tell my Application Components, to perform
> their next task (based on a Custom Event, that I broadcast).
>
> Can anybody show me how to Broadcast Events in such a manner, that they
> get disseminated "Application-wide"???  This way, I don't need to know
> beforehand, which Components will be Receiving the Events.
>
> This is the final thing on my plate that I must figure out, then I can
> FINALLY finish my app and find some peace in my life....
>
> Thanks in advance,
>
> Mike
>

Reply via email to