Archive for the 'Adobe Flash' Category

Asset SWF, loading/embedding has fundamental differences

Embed or getDefinition

So after a few headaches I arrived at a thesis (at best): If developing and compiling in Flex Builder, but using a library of assets (in the form of a SWF-file) compiled by the Flash IDE, loading the assets.swf at runtime and embedding are not going to give you equal access the assets and their associated classes. Loading the asset SWF will enable you to use:

loader.contentLoaderInfo.applicationDomain.getDefinition("MySymbolClass")

That will return a class definition of the library symbol and it’s associated custom class and base class.

However:

[Embed(source="assets.swf", symbol="MySymbol")]
var MySymbolClass:Class;

will yield, put simply, the most descriptive, built-in class able to describe the symbol. But that’s at the discretion of the compiler. So if I have a button with an associated custom class, let’s say FancyButton, in assets.swf, that code will be elegantly ingnored by the Flex compiler and I’m only able to datatype the button as Sprite or MovieClip (if it has more than one frame). So I’m guessing the philosophy behind the embed compiler directive is that it is meant for embedding primitive assets, like bitmaps, sprites, fonts and so on into the class that adds the fancy, custom code, while loading and using getDefinition is the only way that will allow the assets to have custom code associated with them.

As seen in the photo comic above from the 70′, this discussion might have been going on for a while without me knowing it. I think I will be loading my asset SWF at runtime from now on unless someone has a good reason for me not to.

Flash On The Beach - Thank You!

The Old Ship Hotel bar filled to the limit with beer-loving flash developers

The Old Ship Hotel bar filled to the limit with beer-loving flash developers

Just wanted to say thank you to everyone who ran and attended Flash On The Beach ‘08 in Brighton. I had a great time! Here’s a photo I wanted to share. It’s from the Old Ship Hotel bar tuesday night after The Honey Club ran out of beer in just one hour. It was taken with my camera phone, so please excuse the quality.

After the conference I got to kill a few hours in London, so I went to Hamleys to buy the mandatory travel gift for my son. And man do they have some fascinating stuff there. This is a 23 carat gold plated model of a Mercedes SLK which was explicitly stated “Not for sale”. Check it out:

SWFHeader - an alternative to sIFR custom font flash header

SWFHeader

I while ago I worked on a HTML site that would implement sIFR for a custom header font. This was my first attempt at using it and I decided I didn’t really like it that much. Mostly because of the large JavaScript files needed.

I thought to myself that making my own solution needn’t bee so hard so I did. Here it is; introducing SWFHeader!

It works roughly the same way as sIFR does, but it’s a whole lot more stripped down. Like sIFR you edit a FLA-file to embed the font you want to use and export it. Then you insert a few lines into your HTML page and include the JavaScript file required. Now I recognize the fact that sIFR’s code probably is as vast as it is for a reason. Maybe it has better legacy browser support, I don’t really know. What I do know is SWFHeader has worked fine for me and behaves well in IE6+7, Safari and Firefox, and that’s enough for me.

If you’re interested then take it for a spin. There are no fascinating terms of usage to tick off a check box for, nor are there any guarantees. Merely my own experience. Therefore I recommend you test it properly. If you like it (or not) please let me know!

Here are the files:

zip.gif SWFHeader.zip