Archive for the ‘Adobe Flash’ Category

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.

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.