[转]Using a custom flex-config.xml file in Flex Builder 3

The following example shows how you can use a custom configuration file in a Flex Builder Flex project by specifying an additional compiler argument, -load-config.

Full code after the jump.

 

View MXML

<?xml version="1.0" encoding="utf-8"?><!-- http://blog.flexexamples.com/2008/12/21/using-a-custom-flex-configxml-file-in-flex-builder-3/ --><mx:Application name="LoadConfig_fonts_test"        xmlns:mx="http://www.adobe.com/2006/mxml"        layout="vertical"        verticalAlign="middle"        backgroundColor="white">    <mx:Style>        @font-face {            src: url("assets/ARIAL.TTF");            fontFamily: "ArialEmbedded";            unicodeRange: "englishRange";        }        Text {            fontFamily: "ArialEmbedded";            fontSize: 32;            color: red;        }    </mx:Style>    <mx:ApplicationControlBar dock="true">        <mx:Form styleName="plain">            <mx:FormItem label="alpha:">                <mx:HSlider id="slider"                        minimum="0.0"                        maximum="1.0"                        value="1.0"                        snapInterval="0.05"                        tickInterval="0.1"                        liveDragging="true" />            </mx:FormItem>        </mx:Form>    </mx:ApplicationControlBar>    <mx:Text id="txt" width="300" alpha="{slider.value}">        <mx:text>The quick brown fox jumps over the lazy dog. 1234567890 ©</mx:text>    </mx:Text></mx:Application>

Next, create a custom configuration XML file named fontConfig.xml and save it in a /config/ subdirectory in your project’s /src/ directory. The folder structure isn’t important, but it helps keep the source code and configuration files separated. The fontConfig.xml file is a modified version of the flex-config.xml file found in the Flex SDK’s /frameworks/ directory. In this example we simply specify a single named font range which specifies a unicode range of U+0020 (space) to U+007E (~).

config/fontConfig.xml

<?xml version="1.0"?><flex-config>   <compiler>      <fonts>          <!-- Defines ranges that can be used across multiple font-face declarations. -->          <!-- See flash-unicode-table.xml for more examples. -->          <languages>              <language-range>                  <lang>englishRange</lang>                  <range>U+0020-U+007E</range>              </language-range>          </languages>      </fonts>   </compiler></flex-config>

Finally, in Flex Builder, right click on the Flex Project folder in the Flex Navigator and select Properties from the context menu. Select the Flex Compiler section of the dialog menu and in the Additional compiler arguments: text box add the following text:

-load-config+=config/fontConfig.xml


Figure 1. Additional compiler arguments.

View source is enabled in the following example.

posted @ 2009-12-16 10:00  AooYu  阅读(425)  评论(0编辑  收藏  举报