Posts Tagged ‘as3’

An alternative to bitmap transparency in Flash

When it comes to using transparent bitmap images in Flash often you will find using a PNG is your best option. However, a major caveat with using PNG images is the significant increase in file size compared to non-transparent image types such as JPEGs and (non-transparent) GIFs. This often becomes an issue when working on projects with limited allocated file size, such as banner ads.

growing-a-bonsai-tree_sml_faux_transparent
A transparent PNG of the above image has a file size of approximately 109kB

Lately I’ve been toying with an alternative to PNGs… using JPEGs. “Wait a minute…”, you say, “JPEGs don’t support transparency!”. That’s correct but by making use of Flash’s BitmapData class we can merge two non-transparent images together to make a single transparent image. Even though this method actually requires 2 separate JPEGs the total combined file size is almost always significantly smaller than a single PNG! (more…)

My new portfolio site – williamdady.com

Over the last couple of weeks I have slowly been putting together my new portfolio site, williamdady.com, which has been long overdue.  The site was developed in FlashDevelop and Flash CS4 using the PureMVC framework.

pic1

I had a very specific design goal from the beginning to maintain a modular structure, something that PureMVC was a big help at pulling off. Sections are segregated into their own SWF’s each with an accompanying background SWF which in-turn contains multiple background images.

The main shell, the top-most parent SWF, is responsible for the layout of the modules as well as controlling the navigation. I utilized BulkLoader in the shell to handle the loading of module and background SWF’s as a pair. I’ve used BulkLoader a few times now and I it’s a really handy tool which all AS3 devs should have in their library.
(more…)

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. *Cliff Hall, creator of PureMVC, has commented on this post below noting that once you account for separate functions to handle notifications it is not necessarily shorter than the default way of overriding listNotificationInterests and handleNotification.

Download.

Flash Game Ad Manager – Coming Soon!

In July of last year I wrote a post titled Monetizing your Flash game. Serving your own ads? In it I discussed ways Flash game developers could monetize their games through common methods such as sponsorship and ads. I also proposed a method of ’self serving’ ads in ones own games. I successfully implemented such a method in the two games I’ve published to date, Knight of the Dead and Picross Forever. While I personally have had limited success with privately selling ad space in both games I believe there is definitely value in putting control back into the hands of developers so they have complete control over ads displayed in their games.

In the next week or two I will be releasing an AS3 based class library called Ahrooga Ad Manager dedicated to the remote switching and management of in-game ads. Specifically this will allow game makers to use ANY available ad provider’s code in their game rather than being locked into just one. For example, you could have ad code for Mochiads AND GameJacket embedded in your game and remotely switch between them at your leisure. Want to disable ads all together on a specific domain? You can do that too. It also handles the loading and display of custom ads, either SWF or image based. (more…)