-
Notifications
You must be signed in to change notification settings - Fork 1
Embed
When you use the MXMLC compiler you can embed assets with the following metadata
[Embed(source="something.ext")]
public var something:Class;
This embed metadata can have different options
[Embed(source="file.ext")]
[Embed(source="file.ext", mimeType="mime")]
etc.
You can embed different formats
- bitmap
- jpg/jpeg
- png (with 8bit alpha)
- gif (with 1bit alpha, no animation)
- vector
- svg
- svg xml (no animation or scripting)
- audio
- mp3
- font
- ttf
- otf
- ttc
- dfont
- binary
- swf (special case)
- any type
-
source:
example:[Embed(source="file.png")]
Specifies the name and path of the asset to embed;
either an absolute path or a path relative to the file containing the embed statement.
The embedded asset must be a locally stored asset.
Therefore you cannot specify a URL for an asset to embed. -
mimeType:
example:[Embed(mimeType="image/png")]
Specifies the mime type of the asset. -
smoothing:
example:[Embed(smoothing=true)]
Specifies whether the bitmap is smoothed when scaled.
Iftrue
, the bitmap is smoothed when scaled.
Iffalse
, the bitmap is not smoothed when scaled.
This property can be used with any image format. -
compression:
example:[Embed(compression=true)]
For lossless images only (GIF and PNG)
specifies to compress the embedded image in the generated SWF file. -
quality:
example:[Embed(quality=80)]
If you specifycompression=true
, specifies a percentage value,
between 0 and 100, to control the compression algorithm.
The lower the value, the higher the amount of compression. -
scaleGridTop:
example:[Embed(scaleGridTop=0)]
Specifies the distance in pixels of the upper dividing line from the top
of the image in a 9-slice scaling formatting system.
The distance is relative to the original, unscaled size of the image. -
scaleGridBottom:
example:[Embed(scaleGridBottom=0)]
Specifies the distance in pixels of the lower dividing line from the top
of the image in a 9-slice scaling formatting system.
The distance is relative to the original, unscaled size of the image. -
scaleGridLeft:
example:[Embed(scaleGridLeft=0)]
Specifies the distance in pixels of the left dividing line from the left side
of the image in a 9-slice scaling formatting system.
The distance is relative to the original, unscaled size of the image. -
scaleGridRight:
example:[Embed(scaleGridRight=0)]
Specifies the distance in pixels of the right dividing line from the left side
of the image in a 9-slice scaling formatting system.
The distance is relative to the original, unscaled size of the image. -
symbol:
example:[Embed(symbol="SymbolName")]
example:[Embed(source="file.swf#SymbolName")]
Specifies the symbol in a SWF file to embed,
for use with Adobe Flash Player 8 and earlier,
and for Flash Player 9 static assets.
Use static assets for simple artwork or skins that do not contain any ActionScript 3.0 code. -
fontName:
example:[Embed(fontName="ArialBold")]
Define the font name associated with the embedded font.
This is thefont
parameter of theTextFormat
object.If you embed a system font you can not use the same string for the font name
eg.[Embed(systemFont="Arial", fontName="ArialRegular")]
if you use the same name, for ex:[Embed(systemFont="Arial", fontName="Arial")]
the compiler will throw a warning. -
fontFamily:
example:[Embed(fontFamily="Arial Bold")]
Sets the alias for the font that you use to apply the font in style sheets.
This property is required.
If you embed a font with a family name that matches the family name of a system font,
the Flex compiler gives you a warning.
You can disable this warning by setting theshow-shadows-system-font-warnings
compiler option tofalse
. -
fontStyle:
example:[Embed(fontStyle="normal")]
values: "normal", "italic", "oblique"
undocumented: "plain", etc.
Set the style type face value for the font.
This property is optional, unless you are embedding a face that requires it.
The default value is "normal". -
fontWeight:
example:[Embed(fontWeight="bold")]
values: "normal", "bold", "heavy"
undocumented: "plain", "700", etc.
Set the weight type face value for the font.
This property is optional, unless you are embedding a face that requires it.
The default value is "normal". -
embedAsCFF:
example:[Embed(embedAsCFF="false")]
values: "true", "false"
Indicates whether to embed an FTE-enabled font for components.
Flash Text Engine (FTE) is a library that provides text controls with a rich set of formatting options.For Flex 4 and later, the default value is
true
.
If you set thecompatibility-version
compiler option to3.0.0
, then the default value isfalse
.If you set the
embedAsCFF
property totrue
, then you can use the advanced formatting features of
FTE such as bidirectional text, kerning, and ligatures.
If you set the value ofembedAsCFF
tofalse
, then the embedded font does not support FTE,
and works only with the MX text components. -
advancedAntiAliasing:
example:[Embed(advancedAntiAliasing="file.ext")]
values: "true", "false"
Determines whether to include the advanced anti-aliasing information when embedding the font.This property is optional and only used for legacy fonts.
This property is ignored if you embed a font with theembedAsCFF
property set totrue
.You cannot use this option when embedding fonts from a SWF file because this option requires access
to the original, raw font file to pre-calculate anti-aliasing information at compile time. -
unicodeRange:
example:[Embed(unicodeRange="U+0041")]
(single char)
example:[Embed(unicodeRange="U+0041-007F")]
(range)
example:[Embed(unicodeRange="U+0041,U+0043-00FF,U+0045")]
(multiple range)
format:U+[beginning of range]-[end of range]
Specify a range (or subset) of characters that compose the face of an embedded font.
Each character in a font that you use must be described;
removing some of these characters reduces the overall size of the description information
that Flex must include for each embedded font. -
systemFont:
example:[Embed(systemFont="Arial")]
example:[Embed(systemFont="Trebuchet Ms")]
replace optionsource
Allows to embed a system font.
It will embed the font defined by "name" from the computer's Fonts folder. -
source:
example:[Embed(source="file.ext")]
test
options: source
, mimeType
, smoothing
, compression
, quality
MIME Types:
- "image/gif"
- "image/jpeg"
- "image/png"
[Embed(source="file.ext", mimeType="mime", scaleGridTop=0, scaleGridBottom=0, scaleGridLeft=0, scaleGridRight=0)]
options: source
, mimeType
MIME Types:
- "image/svg"
- "image/svg-xml"
options: source
, mimeType
MIME Types:
- "audio/mpeg"
package assets.
{
import flash.media.Sound;
// extends Sound
[Embed (source = "music.mp3")]
public class SoundTrack extends Sound
{
public function SoundTrack(){}
}
}
import flash.media.Sound;
var sound:Sound = new SoundTrack() as Sound;
sound.play();
options: source
, mimeType
MIME Types:
- "application/x-font" (system font)
- "application/x-font-truetype"
options: source
, mimeType
MIME Types:
- "application/x-shockwave-flash" (SWF file)
- "application/octet-stream"
[Embed(source="file.swf", symbol="SymbolName")]
[Embed(source="file.swft#SymbolName")]
[Embed(source="file.ttf", mimeType="application/x-font", fontFamily="name", fontStyle="name", fontWeight="name", advancedAntiAliasing="true", embedAsCFF="false")]
see
- Adobe Flex 4.6 - Embedding asset types
- Adobe Flex 4.6 - Syntax for embedding assets
- Adobe Flex 4.6 - Embed fonts / Using the fontswf utility
- Flex loves Flash
- Embedding assets with mxmlc as flash.display.BitmapData
- Using mxmlc Embed fonts with TextField
- FontSwf Utility in FLEX SDK 4
- Font issue in MinimalComps
- ASC 2.0 Font SWF Embedding
dead