On a recent flex project we had some complex animation – including alpha masks – to be embedded. Not sure why, but when embedding flash files in Flex with the tag, all action script is stripped out. It would be interesting to hear Adobe’s reasoning on this one, but here’s a solution to keeping the embedded swf’s actionscript intact.
The first step is to embed the SWF in your Flex project as binary data:
[Embed(source="complex.swf", mimeType="application/octet-stream")] var theBytes:Class;
Next you need to load the data contained in your SWF by using Loader.loadBytes and instantiate the embedded SWF.
var loader:Loader = new Loader(); loader.loadBytes(new theBytes());
This will create your swf and if all you need is the actionscript to run, you can stop here.