1.到Flex SDK3.2的bin下运行命令:copylocale en_US zh_HK
2.在flex project下创建一个文件夹locale(与src同目录),在locale下分别创建en_US, zh_HK子目录在子目录下各创建一个message.properties文件
3.在FLEX项目中
右键—>Properties—>Flex Build Path->Source path—>Add Folder
在弹出的输入框中输入 locale\{locale}
4.在FLEX项目中
右键—>Properties—>Flex Compiler
在Additional compiler arguments选项的最后面-locale en_US 文件后添加 zh_HK
5.样例
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.resources.ResourceManager;
private function changeLocale(locale:String):void{
resourceManager.localeChain=[locale];
}
]]>
</mx:Script>
<mx:Metadata>
[ResourceBundle("admin")]
</mx:Metadata>
<mx:ApplicationControlBar width="400">
<mx:Label text="Content" width="100%"/>
<mx:Button label="eng" click="changeLocale('en_US')" />
<mx:Button label="ch" click="changeLocale('zh_HK)" />
</mx:ApplicationControlBar>
<mx:Text text="{resourceManager.getString('message','login_label')}" />
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
<![CDATA[
import mx.resources.ResourceManager;
private function changeLocale(locale:String):void{
resourceManager.localeChain=[locale];
}
]]>
</mx:Script>
<mx:Metadata>
[ResourceBundle("admin")]
</mx:Metadata>
<mx:ApplicationControlBar width="400">
<mx:Label text="Content" width="100%"/>
<mx:Button label="eng" click="changeLocale('en_US')" />
<mx:Button label="ch" click="changeLocale('zh_HK)" />
</mx:ApplicationControlBar>
<mx:Text text="{resourceManager.getString('message','login_label')}" />
</mx:Application>