The LocalEventMap tag has the same functionality and inner tags as the EventMap tag. The main difference is that the LocalEventMap will only listen to events dispatched by a given dispatcher (unless specified otherwise in the EventHandlers tags). Therefore, when using this tag, you need to specify the event dispatcher to which the event map will add event listeners.

The best application for a LocalEventMap is when you use modules. If, for some reason, you wanted to have an event map that handled events coming from the module only (while ignoring events of the same type dispatched elsewhere), then you can create a LocalEventMap, and include in your module. Please note that you can use the LocalEventMap anywhere, not just in modules, and this is only a usage example:

<mx:Module ...>
   <maps:MyLocalEventMap dispatcher="{this}" />

Then you create the LocalEventMap in a file called MyLocalEventMap.mxml, extending from LocalEventMap:

<LocalEventMap xmlns="http://mate.asfusion.com/">

   <EventHandlers type="myEventType">
      ... here what you want to happen when this event is dispatched...
   <EventHandlers type="myOtherEventType">
      ... here what you want to happen when this other event is dispatched...

4 responses so far

  1. Another great advantage of the local event map that needs pointing out is the fact that it provides another (i.e. local) scope for object instances, as compared to the global scope of the main event map.

    A very good usage example of this is given in the official Mate examples, look for the "documentbased" project. Have a look at the DocumentView.mxml file and function createOpenedDocuments() in MainView.mxml

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!

Leave this field empty