How to embed an entire asset SWF and get symbols from it

The problem:

You want to embed an entire SWF, full of assets, into a class and retrieve individual symbols from it – but you don’t want to have to embed each asset individually.

The solution:

SWFAsset – a couple of lines of code and you’re away.

Posted in AS3 | Tagged , , , , | 3 Comments

Blue lego block of ambiguity

The blue lego block of ambiguity :(At the risk of getting sucked into the Apple vs Adobe shitstorm, my own response to Apple chosing to block Flash content from their mobile devices is to at least tell users why – because Apple left it at the rather obscure blue lego block, with no explanation (great experiential design guys). Simply include this code in your page/s to redirect mobile safari users to a page of your chosing …I direct them here.

Posted in Flash, Politics | Tagged , , , | Leave a comment

How to correct 3-D projection on stage resize

The problem:
You're using Flash 10's native 3-D API and notice the projection goes a little skewiff when resizing the window.

The solution:
You need to reset the stage's projection centre on stage resize, like so...

Actionscript:
  1. var centre:Point = new Point(stage.stageWidth/2, stage.stageHeight/2);
  2. root.transform.perspectiveProjection.projectionCenter = centre;

Posted in 3D, AS3, Flash | Tagged , , , , | Leave a comment

Migrating to Flex SDK 4

In moving to compiling projects with the new Flex SDK 4, in noticed a couple of gotchas to do with the EMBED metatag that I thought I'd better share:

Runtime shared libraries
If you're like me and want to embed assets in your project with the EMBED Flex metatag, so you can manage and update things easily, there's a an extra compiler parameter you must add, in order for your project to compile properly:

--static-link-runtime-shared-libraries=true

This is already added as a new default parameter to the new version of FlashDevelop. But if you're planning to build projects from outside of FlashDevelop, you must add this to your compiler string. Otherwise, the compiler will think you have uninitialised constants and warn you so.

Embedding fonts
Using the EMBED metatag (or 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 you need to install that you can't find is crazy. With Flex SDK 4, you'll need to add an extra attribute to your embed tag for fonts, called 'embedAsCFF':

Actionscript:
  1. [Embed(source='myfont.ttf', fontName='MY_FONT', fontWeight='regular', unicodeRange='U+0020-U+0040,U+0041-U+005A', mimeType='application/x-font', embedAsCFF='false')]
  2. public static const MY_FONT :Class;

Posted in AS3, Flash | Tagged , , , , | Leave a comment

FlashSize – simple browser resizing

How to allow SWFs to display at 100% width/height in your browser - but enforce a minimum width and height, in case of a smaller browser window size than you've designed for.

Until recently, I'd used other Flash/browser resize managers when I needed to ensure a SWF is embedded in HTML at 100% width and height, but with support for a minimum width and height setting. But I recently needed a solution the didn't depend on external JavaScript, due to not having control of the page the SWF is embedded in.

With my simple FlashSize script, all you need do is call:

Actionscript:
  1. import com.spikything.utils.FlashSize;
  2. FlashSize.setup(minWidth, minHeight);

Posted in AS3, Flash | Tagged , , , | Leave a comment