Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Created May 5, 2010 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasonm23/391446 to your computer and use it in GitHub Desktop.
Save jasonm23/391446 to your computer and use it in GitHub Desktop.
Embed types for AS3 & Flex
// Embed types for AS3 & Flex
/*
Note, mxmlc recognizes your src folder "Default Package" as '/' (root) when using:
[Embed], source="@Embed('')" or @font-face tags.
For example... if your assets folder is a sibling of the src folder, you access using
the slightly odd path:
/../assets/
Embed automatically transcodes these filetypes:
JPG/JPEG, GIF, PNG and SVG/SVGZ image files (supports a subset of SVG 1.1)
MP3 sound files
TTF font files (use @font-face to embed these)
Installed system fonts
SWF files and specific symbols inside them
*/
// Supported Image types...
[Embed(source="/../assets/images/image.png")]
[Embed(source="/../assets/images/image.jpg")]
[Embed(source="/../assets/images/image.gif")]
// Scale 9 - works for all image types
[Embed(source="/../assets/images/slice_9_grid.gif",
scaleGridTop="25", scaleGridBottom="125",
scaleGridLeft="25", scaleGridRight="125")]
// SVG
[Embed(source="/../assets/svg/drawing.svg")]
// SWF
[Embed(source = "/../assets/Asset.swf", symbol = "videoSymbol1")]
[Embed(source = "/../assets/Asset.swf)]
// MP3
[Embed(source="/../assets/audio/song.mp3")]
// Any other file can be embedded as application/octet-stream
// As long as you can read it (from a ByteArray) Usually you will be able
// to port a format reading routine from C or other source.
[Embed(source="/../assets/any/anyfileformat.ext",mimeType="application/octet-stream")]
// XML is a special edge case, use text/xml e.g.
[Embed(source="/../xml/test.xml", mimeType="text/xml")]
private var EmbedXml:Class;
//... elsewhere in method code:
var xml:XML = new XML(new EmbedXML());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment