小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

在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>

posted on 2008-04-27 17:22  『小小菜鸟』  阅读(1235)  评论(0编辑  收藏  举报