« Spry Review Part1(JP) | Main | Spry Review Part2(JP) »

First Flex Day

Flash 9 does not work on Intel mac because of bugs of the compiler with java, however I will try to study as3 with adobe flex. Terminal is required to compile mxml to swf with command line on mac, but its not familiar with most of mac users that have no knowledge of about unix. Use it in your terminal like this:

mxmlc --strict=true --file-specs MyFirst.mxml
In strict mode, the compiler has higher expectations of your code. --file-specs is used to specify mxml file to be compiled.

Embedding Images

<mx:Script>
        <![CDATA[
            [Embed(source="assets/logo.png")]
            [Bindable]

            public var Logo:Class;            
        ]]>
</mx:Script>
<mx:Image id="myLogo" source="{Logo}"/>

You can gild-line properties for tag to create scale-grid.

[Embed(
      source="assets/fancy_border.png", 
      scaleGridTop="55", scaleGridBottom="137", 
      scaleGridLeft="57", scaleGridRight="266"
)]

Embedding SWFs

[Embed(source="assets/hourglass.swf")]

The symbol property of tag is used to specify the Linkage ID of the symbol in the library.

[Embed(source="assets/library.swf", symbol="BadApple")]

Embedding MP3

[Embed(source="assets/pie-yan-knee.mp3")]
Embedding fonts
To specify characters to be embed using the unicode-range property of @font-face saves file size.
<mx:Style>
        @font-face 
        {
            font-family: Copacetix;

            src: url("assets/copacetix.ttf");
            unicode-range:
                U+0020-U+0040, /* Punctuation, Numbers */

                U+0041-U+005A, /* Upper-Case A-Z */
                U+005B-U+0060, /* Punctuation and Symbols */
                U+0061-U+007A, /* Lower-Case a-z */
                U+007B-U+007E; /* Punctuation and Symbols */

        }
        .MyTextStyle 
        { 
            font-family: Copacetix; 
            font-size: 24pt;    
        }
</mx:Style>

Post a comment