[Flash&flex] AS3.0 How to embed resources using [Embed (Source= ... ")]

Source: Internet
Author: User

In Flex and Flashide we can [Embed (source= "...")] embed resources such as images and SWF, but there are different ways to embed them.

Flex Example:

[Embed (Source="). /assets/images/embed/bg_top_v.png "publicvar bg_top_v:class;

Flash Example:

[Embed (Source="/. /assets/images/embed/bg_top_v.png "publicvar bg_top_v:class;

".. /" indicates that a lookup is started from the parent directory of the publishing directory, and this string is not required if the resource is in a sibling directory of the publishing directory.

Note the difference between the two, and you must also set up the Flex SDK in the Flash IDE, because the [Embed (source= ...]] method itself belongs to the functionality of the Flex SDK.

Also attached are methods for embedding other types of data:

"/.. /assets/app/weather/config/city.xml"" Application/octet-stream ")]publicvar 

When embedding XML data, you must set the MimeType parameter to "Application/octet-stream". Flash cannot detect the correct MIME type through the extension of the XML file, so you set the mimetype parameter whenever you embed the XML data.

[Embed (source="Arial bold.ttf", fontname="MyFont", fontweight="Bold", advancedantialiasing="True", mimetype="Application/x-font")]     public  var

When embedding font data, Source: This parameter indicates the location of the font file. If you prefer, you can use the Systemfont parameter to confirm the name instead of the source to embed the system font. FontName: This parameter indicates the name of the embedded font, and the name of the font is a unique identifier, so you can call the font by name. MimeType: This parameter describes the MIME type of the embedded metadata. Because you embed a font in this example, you can set the MIME type to "Application/x-font". FontWeight: This parameter indicates the weight of the font, such as bold or normal.

Note: If the font has a thickness and you do not include the fontweight parameter in the [Embed] metadata label, when the test SWF file is, you will see the following compilation error:

Exception during Transcoding:font for alias ' MyFont ' with plain weight and style is not found at ... (Unexpected conversions: fonts with a thickness and style alias of ' MyFont ' are not found in ...)

[Flash&flex] AS3.0 How to embed resources using [Embed (Source= ... ")]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.