I spent a good few hours trying to get the Mate framework working yesterday using the famous Cafe Townsend example. It was time well spent as I plunged quite deep into the architecture; putting my failures down to syntax and short-sightedness. I soon realised that something much deeper was wrong however and a quick look at the Mate forums revealed this post with this gem …
It seems the problem sticks inside SystemManager which GlobalDispatcher uses
… it seems that the use of Application.application in the framework was preventing the global events being dispatched from the SystemManager. In Flex 4 you use FlexGlobals.topLevelApplication to return the main Application class.
A member of the team soon posted a patch which (at the time of writing this post) is available here. Now, this is the reason for posting this information: anyone who may find themselves in the same situation that I was yesterday should NOT download the latest SWC for the Mate framework you’ll find this ‘fix’ is NOT in place. You’ll need the patch to publish using the Flex 4 sdk.
While I’m at it. Here’s my Cafe Townsend Mate example ported to Flex 4 with some of the code for you to check out. The only change is the use of the Spark Application tag and the Declarations tag. I did remove the Styles with the intention to put them back at some point but I don’t think I can be arsed now. You’ll just need to grab the code from the Flex 3 example and put it back. The views are the same. Grab the source here.
[note: RSS readers will not display the iFrame below]
Here’s the Application class. Note the Declarations tag and the EventMap classes. Don’t get caught out by this. You need to use the Declarations tag for non-visual components in your Application class.
What I like about Mate is the how minimal you can keep your views. Notice how I’m not listening for any of the FlexEvent events within the App class. Now look at the MainEventMap class …
… all your events are handled in here which makes your code really neat and the views end up being nicely decoupled from the logic and functionality.
Anyhoo, I hope this has saved someone a few hours of frustration.


August 6th, 2009 at 10:29 am
[...] Mate Framework and Flex 4 sdk [...]
February 3rd, 2010 at 7:07 am
you really saved me!I just confusing why the event can not reach the handler, until I found your post here, I know I need to declare eventmap in , wish the framework team can add some flex4 spark example on their site.
March 22nd, 2010 at 1:42 pm
[...] – Mate Framework + Flex 4 SDK [...]
March 24th, 2010 at 2:11 am
[...] – Mate Framework + Flex 4 SDK [link post] [...]