PureMVC: Creating a short-hand Mediator

99% of coding I do lately is built on top of the excellent PureMVC framework. Something that has been irking me for a while now is the way Mediators register and handle notifications dispatched from the View.

Part of working with PureMVC requires extending from the Mediator base class (more specifically implementing IMediator) as this contains two important methods, listNotificationInterests and handleNotification. Where this starts to get a little painful is you need to override both of those methods for every Mediator you create. That is where I came up with the idea of abstracting away these two methods by creating a ‘helper method’ which will map a notification to a handler. I should say that before doing this I searched on the PureMVC forums and found several people who have already encountered this issue and created their own implementations.

I’ve created my own extended version of the base Mediator class I’ve called AbstractMediator. This includes a custom method called registerNotificationHandler which you pass a notification name and call back method to. This is very similar to the addEventListener method used in AS3. Then you simply extend AbstractMediator instead of Mediator in your application. AbstractMediator automatically populates the array returned by listNotificationInterests and uses handleNotification to route incoming notifications to the mapped functions, thus you no longer need to explicitly override these.

Overall the main reason I wanted to create this was to significantly shorten the amount of code needed in each Mediator.

Download.

SWFObject 2.2 Out Now!

Just got word that SWFObject 2.2 is now out and available for download.

SWFObject is THE way to embedd Flash content in HTML and is a MUST have for any Flash user. What’s great about SWFObject is it’s ability to degrade gracefully across various browsers by either throwing up a Flash express install dialog or alternate non-flash content.

Check out the What’s New page over at Google Code to see the latest features and changes.

Flash Ad Manager v1.0 Now Available

Flash Ad Manager is now available to download as a 1.0 release from the Google Code project page.

If you missed the previous posts about it, here’s the spiel:

Flash Ad Manager lets developers remotely display custom or embedded ads during the preloading stage of a Flash application.

My main motivation with this project is to give Flash Platform developers, specifically Flash game developers, better control over how they monetize their work through the use of ads.

Currently the 2 major sources for Flash game monetization are sponsorship and advertising. With this package I hope to open up a potentially untapped area for developers, self served ads as well as provide a way for games to be released without having to be “locked in” to a single ad API like MochiAds. (more…)

Help fix Flash’s visible dimensions

Colin Moock, author of the excellent book Essential Actionscript 3.0 has written an interesting blog post regarding an issue which Flash (still) has with finding the visible dimensions of a DisplayObject. The key word there being “visible” as the way Flash currently reports a DisplayObject’s size does not account for things which effect on-screen appearance such as masking. For example if you have a 40×40 DisplayObject with a 20×20 mask the getBounds method, as well as the width and height properties, report the DisplayObject as being 40×40, which is technically correct, but Flash currently has no way of easily reporting the actual visual (masked) size.

Colin has raised this through the Adobe Flash Player and Issue Management System which I urge anyone with even a passing interest in Flash to go and vote for. This is your chance to help shape the future of the Flash player and resolve one of it’s most lacking features.