小小菜鸟的web菜园子

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

导航

使你的TextInput组件只能输入数字.

restrict属性学习.
只能输入数字.
示例:

代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/15/restricting-which-characters-a-user-can-type-in-a-textinput-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white">

    
<mx:Script>
        
<![CDATA[
            private function textInput_change(evt:Event):void {
                arrColl.addItem(evt);
            }
        
]]>
    
</mx:Script>

    
<mx:ArrayCollection id="arrColl" />

    
<mx:ApplicationControlBar dock="true">
        
<mx:TextInput id="textInput"
                restrict
="0-9-"
                change
="textInput_change(event);" />
    
</mx:ApplicationControlBar>

    
<mx:DataGrid id="dataGrid"
            dataProvider
="{arrColl}"
            width
="100%"
            height
="100%" />

</mx:Application>

来自:http://blog.flexexamples.com/2008/05/15/restricting-which-characters-a-user-can-type-in-a-textinput-control-in-flex/

posted on 2008-05-16 14:11  『小小菜鸟』  阅读(2072)  评论(0编辑  收藏  举报