Learning Employee Directory 5.1 Event bubble

24 sec read

Return to table of contents
In ApplicationUI.mxml (init()), you will find the following two lines:

// in ApplicationUI.mxml, in init()
titleControls.addEventListener( "showHelp", showHelpScreen );
addEventListener( "close", closePanel );

This is a little bit strange. One uses titleControls as event listener, the other uses ApplicationUI. It turns out this is due to the bubbling of event.

// in TitleControls.mxml
<mx:Button click="dispatchEvent( new Event('showHelp') )" />
// in EmployeeView.mxml
<mx:Button id="closeBtn" click="dispatchEvent( new Event( Event.CLOSE, true ) )"/>

Note that the “true” argument in the second case. It allows the Event to bubble to the parent components (ApplicationUI). That’s why ApplicationUI can hear the event. If you add “true” argument in the TitleControls.mxml, you can also use ApplicationUI to listen to the event.

Receive email notification via email 博客有新内容通知我

Don't want to miss new papers in your field? Check out Stork we developed:

How much money did I make from an app?

Undoubtedly some people are very successful in making money by developing a smartphone app. Back in 2012 I developed an app called “Handbook of...
Xu Cui
27 sec read

Handy programs to visualize NIRS data (2): plotTopoMap

Often you need to view the spatial pattern of activation as in the example below. plotTopoMap allows you to do that. It probably only...
Xu Cui
37 sec read

Flash 3D video demo

Racer Ostrova Zombie
Xu Cui
0 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *