<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    沙漠中的魚

    欲上天堂,先下地獄
    posts - 0, comments - 56, trackbacks - 0, articles - 119
      BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    Syntax for embedding assets

    Posted on 2008-10-31 21:15 沙漠中的魚 閱讀(343) 評論(0)  編輯  收藏 所屬分類: Flex

    The syntax that you use for embedding assets depends on where in your application you embed the asset. Flex supports the following syntaxes:

    • [Embed(parameter1, paramater2, ...)] metadata tag

      You use this syntax to embed an asset in an ActionScript file, or in an <mx:Script> block in an MXML file. For more information, see Using the [Embed] metadata tag.

    • @Embed(parameter1, paramater2, ...) directive

      You use this syntax in an MXML tag definition to embed an asset. For more information, see Using the @Embed() directive in MXML.

    • Embed(parameter1, paramater2, ...) directive

      You use this syntax in an <mx:Style> block in an MXML file to embed an asset. For more information, see Embedding assets in style sheets.

    All three varieties of the embed syntax let you access the same assets; the only difference is where you use them in your application.

    Escaping the @ character

    You can use the slash character (\) to escape the at sign character (@) when you want to use a literal @ character. For example, the string "\@Embed(foo)" means the literal string "@Embed(foo)"). You use two slash characters (\\) to escape a single backslash character. For example, use the character string "\\@" to specify the literal strings "\@".

    Embed parameters

    Each form of the embed syntax takes one or more optional parameters. The exact syntax that you use to embed assets depends on where they are embedded. Some of these parameters are available regardless of what type of asset you are embedding, and others are specific to a particular type of media. For example, you can use the source and mimeType parameters with any type of media, but the scaleGridRight parameter applies only to images.

    The following table describes the parameters that are available for any type of embedded asset. For more information, see About the source parameter and About the MIME type.

    Parameter

    Description

    source

    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.

    For more information on setting the path, see About setting the path to the embedded asset.

    mimeType

    Specifies the mime type of the asset.

    The following table describes the parameters that are specific for images and Sprite objects. For more information, see Using 9-slice scaling with embedded images.

    Parameter

    Description

    scaleGridTop

    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

    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

    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

    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.

    The following table describes the parameter that is specific to SWF files. For more information, see Embedding SWF files.

    Parameter

    Description

    symbol

    Specifies the symbol in a SWF file to embed, for use with Adobe Flash Player 8 and earlier.

    About the source parameter

    In almost all cases, you must specify the source parameter, or nothing is embedded.

    The source parameter is the default parameter of the [Embed] metadata tag; therefore, if you are not specifying any other parameters, you can just supply its value without explicitly including the parameter name or assigning it the desired value, as the following example shows:

    <mx:Style>    
        .myCustomButton {
            overSkin:Embed("overIconImage.gif");
            upSkin:Embed(source="upIconImage.gif");
            downSkin:Embed(source="downIconImage.gif");
        }
    </mx:Style>

    About setting the path to the embedded asset

    You can specify a fully qualified path to the image or a URL, as the following examples show:

    <mx:Button label="Icon Button" 
        icon
    ="@Embed(source='c:/myapp/assets/logo.gif')"/>
    <mx:Button label="Icon Button" 
        icon
    ="@Embed(source='http://host.com/myapp/assets/logo.gif')"/>
    Note: Do not use the backslash character (\) as a separator in the path.

     

    If the path does not start with a slash character, Flex first searches for the file relative to the file that contains the [Embed] metadata tag. For example, the MXML file testEmbed.mxml includes the following code:

    <mx:Button label="Icon Button" icon="@Embed(source='assets/logo.gif')"/>
    

    In this example, Flex searches the subdirectory named assets in the directory that contains the testEmbed.mxml file. If the image is not found, Flex then searches for the image in the SWC files associated with the application.

    If the path starts with a slash character, Flex first searches the directory of the MXML file for the asset, and then it searches the source path. You specify the source path to the Flex compiler by using the source-path compiler option. For example, you set the source-path option as the following code shows:

    -source-path=a1,a2,a3
    

    The MXML file a1/testEmbed.mxml then uses the following code:

    <mx:Button label="Icon Button" icon="@Embed(source='/assets/logo.gif')"/>
    

    Flex first searches for the file in a1/assets, then in a2/assets, and then in a3/assets. If the image is not found, Flex searches for the image in the SWC files associated with the application.

    If the MXML file is in the a2 directory, as in a2/testEmbed.mxml, Flex first searches the a2 directory and then the directories specified by the source-path option.

    About the MIME type

    You can optionally specify a MIME type for the imported asset by using the mimeType parameter. If you do not specify a mimeType parameter, Flex makes a best guess about the type of the imported file based on the file extension. If you do specify it, the mimeType parameter overrides the default guess of the asset type.

    Flex supports the following MIME types.

    • application/octet-stream
    • application/x-font
    • application/x-font-truetype
    • application/x-shockwave-flash
    • audio/mpeg
    • image/gif
    • image/jpeg
    • image/png
    • image/svg
    • image/svg-xml

    Using the [Embed] metadata tag

    You can use the [Embed] metadata tag to import JPEG, GIF, PNG, SVG, SWF, TTF, and MP3 files.

    You must use the [Embed] metadata tag before a variable definition, where the variable is of type Class. The following example loads an image file, assigns it to the imgCls variable, and then uses that variable to set the value of the source property of an Image control:

    <?xml version="1.0"?>
    <!-- embed\ImageClass.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        width
    ="100" height="80" borderStyle="solid">
        
        
    <mx:Script>
            
    <![CDATA[
                [Embed(source="logo.gif")]
                [Bindable]
                public var imgCls:Class;
            
    ]]>
        
    </mx:Script>

        
    <mx:Image source="{imgCls}"/>
    </mx:Application>

    主站蜘蛛池模板: 国产亚洲欧洲精品| 国产午夜亚洲不卡| 久久精品国产亚洲AV忘忧草18| 青青青国产手机频在线免费观看| 亚洲一区二区高清| 一本久久免费视频| 亚洲精品乱码久久久久久久久久久久| 中文字幕无线码免费人妻| 亚洲精品乱码久久久久久| 久久香蕉国产线看免费| 亚洲av福利无码无一区二区| 久久国产色AV免费观看| 亚洲AV无码久久久久网站蜜桃 | 亚洲第一视频在线观看免费| 永久免费精品影视网站| 亚洲国产精品无码专区影院| 久久久高清日本道免费观看| 久久av无码专区亚洲av桃花岛| 亚洲精品国产免费| 亚洲国产av玩弄放荡人妇| 亚洲 国产 图片| 成人爽a毛片免费| 亚洲国产精品无码久久久| 嫩草影院在线免费观看| 特级毛片A级毛片免费播放| 亚洲精品无码成人片久久| 黄色网址免费大全| 成人精品综合免费视频| 亚洲国产精品lv| 成人人观看的免费毛片| 国产福利电影一区二区三区,免费久久久久久久精 | 无码人妻久久一区二区三区免费 | 国产成人无码免费视频97| 一级成人生活片免费看| 亚洲国产精品自在在线观看 | 亚洲性无码av在线| 国产美女无遮挡免费网站| 亚洲免费人成在线视频观看 | 亚洲电影一区二区| 永久免费看mv网站入口| 特级无码毛片免费视频尤物|