Just downloded and installed Flex and working my way through
the tutorials (looks brilliant). However the 'event' tutorial shows
two ways of creating an event and associating it with an object.
The first is using the design view to place a function call in the
'click' property for the object - one line, takes seconds to
insert. The second method involves writing several lines of
actionscript and MXML in three seperate locations.
What am I missing here? Why on earth would someone choose the
second (actionscript) method when the MXML method takes seconds and
is much less complex?
When you declare an event listener in the MXML, what you're
doing is making the enclosing document a listener for the event.
This works fine for most simple situations. However, there will be
times when other objects in your application need to listen to a
component's events, and those listeners must register themselves
Also, a far more common use of addEventListener() is for
components created at runtime via AS. In that case, event listeners
can be registered using only AS.