Modules

Mate works with Flex Modules. Depending on your needs, you can have an EventMap within the main application and other event maps included within the modules themselves.

Regardless of where the event maps are placed, however, events dispatched anywhere (in any module) will trigger EventHandlers listening for those event types in all event maps (those included in the main application plus those event maps included in modules that have been loaded).

It is recommended that any event that represents some action that can be shared among modules be handled in an EventMap placed in the main application. In that way, your modules can dispatch events knowing that they will be handled by a shared event map. Any event that is specific to a module, should be placed in an event map that is placed in the module's main file. When the module dispatches this specific event, its own event map will handle it.

Under this configuration, you would have:

  • Main application
  • MainEventMap.mxml
  • Module A
  • ModuleAEventMap.mxml

Lastly, there could be events handled by both the main map and the module's map. If you wish to specify the order by which each event map will handle the event, you can use the priority attribute of the EventHandlers tag.

9 responses so far

  1. Hi,

    What if you want to create two instances of the same module for example, but don't want events from one instance to be heard in the second instance
  2. Never mind, found LocalEventMap
  3. Hi,
    Can a module use injectors?
    I mean, can you inject a manager Class into a module from the main application EventMap?.
  4. Hilary,
    Yes, just like any other view.
  5. Thanks Laura,
    When I inject into the module from the main app, and then try to unload the module, the module is not fully unloaded.

    If I dont inject into the module, the module is unloaded ok.

    Is there a way of removing all injectors and/or references to a module before unloading?

    Hilary

    --
  6. Hillary,
    Use "softbindings" in your injectors.
  7. Am using Flex4 and Mate framework to load Flex module. For this am using module manger load Modules dyanamicaly. But here am getting following error.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.styles::StyleProtoChain$/initProtoChainForUIComponentStyleName()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleProtoChain.as:356]
    at mx.styles::StyleProtoChain$/initProtoChain()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\styles\StyleProtoChain.as:171]
    at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::initProtoChain()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:10186]
    at mx.core::UIComponent/regenerateStyleCache()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:10249]


    it throws error in StyleProtoChain.as. Please suggest me why it is happening.

    same code works in flex3.5.
  8. nithya,
    I don't think the error is due to Mate in any way. A Google search reveals that others have the same problem:
    http://stackoverflow.com/questions/928253/how-do-i-get-rid-of-a-null-styleprotochain-object-reference
    http://forums.adobe.com/thread/609603?tstart=0
  9. Hi laura ,

    I created entire project in mate framework.But i am still feel thats not upto the standard.

    Because i am not used injectors in wise way .Is this bad approach.

    Thanks & Regards
    Sankar

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