在FLEX中使用特殊字符.
%、#、&等特殊字符
示例:
代码:
示例:
代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/02/using-special-characters-in-your-flex-applications/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var charCodes:ArrayCollection;
private function init():void {
charCodes = new ArrayCollection();
var i:int;
for (i = slider.values[0]; i <= slider.values[1]; i++) {
charCodes.addItem({charCodeNum:i, charCodeValue:"&#" + formatString(i) + ";", charCodeStr:String.fromCharCode(i)});
}
}
private function formatString(str:Object, minLength:int = 4):String {
return ("000000000" + str.toString()).substr(-minLength);
}
]]>
</mx:Script>
<mx:VBox>
<mx:DataGrid id="dataGrid" dataProvider="{charCodes}" width="300">
<mx:columns>
<mx:DataGridColumn dataField="charCodeStr" />
<mx:DataGridColumn dataField="charCodeValue" />
</mx:columns>
</mx:DataGrid>
<mx:HBox width="100%">
<mx:HSlider id="slider" minimum="32" maximum="512" thumbCount="2" values="[0, 512]" liveDragging="true" snapInterval="1" tickInterval="32" dataTipPrecision="0" change="init()" />
<mx:Label text="`{dataGrid.selectedItem.charCodeStr}` = {dataGrid.selectedItem.charCodeValue}" selectable="true" />
</mx:HBox>
</mx:VBox>
<mx:Label text="© {new Date().fullYear} Flex Examples" />
</mx:Application>
<!-- http://blog.flexexamples.com/2007/08/02/using-special-characters-in-your-flex-applications/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var charCodes:ArrayCollection;
private function init():void {
charCodes = new ArrayCollection();
var i:int;
for (i = slider.values[0]; i <= slider.values[1]; i++) {
charCodes.addItem({charCodeNum:i, charCodeValue:"&#" + formatString(i) + ";", charCodeStr:String.fromCharCode(i)});
}
}
private function formatString(str:Object, minLength:int = 4):String {
return ("000000000" + str.toString()).substr(-minLength);
}
]]>
</mx:Script>
<mx:VBox>
<mx:DataGrid id="dataGrid" dataProvider="{charCodes}" width="300">
<mx:columns>
<mx:DataGridColumn dataField="charCodeStr" />
<mx:DataGridColumn dataField="charCodeValue" />
</mx:columns>
</mx:DataGrid>
<mx:HBox width="100%">
<mx:HSlider id="slider" minimum="32" maximum="512" thumbCount="2" values="[0, 512]" liveDragging="true" snapInterval="1" tickInterval="32" dataTipPrecision="0" change="init()" />
<mx:Label text="`{dataGrid.selectedItem.charCodeStr}` = {dataGrid.selectedItem.charCodeValue}" selectable="true" />
</mx:HBox>
</mx:VBox>
<mx:Label text="© {new Date().fullYear} Flex Examples" />
</mx:Application>