I recently stumbled upon an old bit of code which demonstrates a technique I created for an efficient scrolling data grid on the YouView TV platform. I call it ‘Blit Scrolling’. Below is a demo of the concept – click on the window and use the arrow keys to scroll around (Flash required): Continue reading Optimal scrolling for 2D games or UIs→
A common oversight in Flash projects, when using a Bitmap with loaded content is that Flash will revert a Bitmap’s smoothing parameter to false when you replace its bitmapData. That is, when the data loads into the Bitmap, anti-aliasing will get turned off. This is simple enough to fix, but since you may not know if someone is going to replace the bitmapData of a Bitmap you have created – then it’s much better to code defensively for it.
This little SmoothBitmap class is for just such an occasion. Instantiate it like a regular Bitmap and, no matter what another developer does with it, smooth, anti aliased pixels when scaling/rotating will be ensured. Enjoy 🙂
If you’re still churning out Flash banners, please use this!
I created this simple utility, called SWFIdle, to enable the Flash Player to lower its CPU usage while the user is not interacting with it. Since it’s possible to have multiple Flash instances embedded in one page (for example, a game and a couple of banners), I recommend using this in your projects, so that Flash instances needn’t fight for CPU and give Flash a worse name than it has already 😉
I know there’s the hasPriority embed attribute now. But:
That assumes you have access to the HTML that embeds your SWF
If no other players are present, it has no effect
There’s still usually little reason to be running your SWF at a high framerate if the user isn’t interacting with it
Flash banners with wastefully unoptimised drawing routines are probably one of the key reasons that Flash got poo-pooed off of mobile platforms and disabled on everyone’s laptops – CPU usage = battery usage!
In moving to compiling projects with the new Flex SDK 4, I noticed a couple of gotchas to do with the EMBED metatag that I thought I’d share:
Runtime Shared Libraries
If you wish to embed assets in your SWF with the EMBED metatag, so you can manage and update things easily, there’s an extra compiler parameter you must add, in order for your project to compile properly:
This is already added as a new default parameter in FlashDevelop projects. But if you’re planning to build projects from outside a similar IDE, you must add this to your compiler string. Otherwise, the compiler will think you have uninitialised constants and warn you so.
Using the EMBED metatag, or even better runtime loading, for fonts is the sensible way forward. The amount of projects I’ve seen where you need to build from an FLA file full of fonts, which you need to hunt down and install is crazy. With Flex SDK 4, you’ll need to add an extra attribute to your embed tag for fonts, called ’embedAsCFF’: