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" verticalalalign = "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: 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 into SS multiple font-face declarations. --> <! -- See flash-unicode-table.xml For more examples. --> <ages> <language-range> <Lang> englishrange </lang> <range> U + 0020-u + 007e </range> </language-range> </ages> </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 inAdditional 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.