flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: EventListener null reference error
Date Sun, 28 Aug 2016 16:52:33 GMT

On 8/28/16, 8:52 AM, "CodeGirl" <MichelleNicholes@yahoo.com> wrote:

>You just wonderfully described what I suspected was causing my problem
>and I
>appreciate that it was designed that way.  Except when it came to my event
>listener.  I need to know in a grand parent when an option is changed at
>grand child level.

IMO, while that is technically true, the principle of encapsulation says
that as events propagate back up from child to parent to grandparent, they
should have increasingly more "semantic" information.  IOW, if an MXML
component has two buttons in it, and each of those buttons dispatch a
"click" event, the code for the MXML component (often put in a controller)
should cause the MXML component to dispatch a "okClicked" and
"cancelClicked" event.  The parent of the MXML component then just listens
to the MXML component, for one of those events and adds more semantic
information to any events it dispatches ("loginOKClicked").  IMO, it is
fine to skip levels/generations, but essentially your code shouldn't have
to dig deep.  The code that adds the semantic information should be
instantiated at the same time as the UI widgets it is listening to.  An
event or your code logic should know when it is switching to the Login
panel and attach listeners then.  That is also Pay-as-you-go: no need
delay startup to attach listeners if the user never goes to that panel.


View raw message