posts - 325,  comments - 25,  trackbacks - 0

          數(shù)據(jù)格式化
          Flex內(nèi)置格式化組件

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF" width="500" height="280">

            <mx:DateFormatter id="dateFormatShort" formatString="MM/DD/YY"/>
            <mx:DateFormatter id="dateFormatMedium" formatString="MMM DD, YY"/>
            <mx:DateFormatter id="dateFormatFull" formatString="MMMM DD, YYYY"/>

           <mx:Panel title="Simple Formatter"
            layout="horizontal" width="100%" height="100%">
              <mx:DateChooser id="cal" />
             
              <mx:VBox>
               <mx:Label text="{cal.selectedDate}"/>
                <mx:Label text="{dateFormatShort.format(cal.selectedDate)}"/>
                <mx:Label text="{dateFormatMedium.format(cal.selectedDate)}"/>
                <mx:Label text="{dateFormatFull.format(cal.selectedDate)}"/>
            </mx:VBox>
             
           </mx:Panel>
          </mx:Application>

          當(dāng)格式化組件出現(xiàn)錯(cuò)誤信息時(shí)
          當(dāng)無錯(cuò)誤時(shí),error屬性返回空字符串,當(dāng)出錯(cuò)時(shí)返回Invalid Data

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF">

            <mx:Script>
              <![CDATA[
              [Bindable]
              public var results:String="";
              public function formatNow():void {
                phoneFormatter.format(phone.text);
                // Check value of error property
                if(phoneFormatter.error == "Invalid value"){
                 // append error to results
                  results+=phoneFormatter.error+" - "+ phone.text + "<br/>";
                } else {
                 // append to results
                  results+="Valid Phone Number - "+phoneFormatter.format(phone.text) + "<br/>";
                  // format original TextInput
                  phone.text=phoneFormatter.format(phone.text);
                }
              }
              ]]>
            </mx:Script>

            <mx:PhoneFormatter id="phoneFormatter"
              formatString="(###) ###-####" validPatternChars="#-() "/>

            <mx:Panel title="Formatter Error Example" width="300" height="300"
              paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

            <mx:HBox>
              <mx:Label text="Phone number:" />
              <mx:TextInput id="phone" width="75%" change="formatNow()" restrict="0-9()-."/>
            </mx:HBox>
            <mx:TextArea id="formatterResults" htmlText="{results}" width="100%" height="100%" editable="false"/>
            </mx:Panel>
          </mx:Application>

          posted on 2011-03-17 09:44 長(zhǎng)春語林科技 閱讀(208) 評(píng)論(0)  編輯  收藏 所屬分類: flex
          <2011年3月>
          272812345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

           

          長(zhǎng)春語林科技?xì)g迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊(cè)

          收藏夾

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 黄山市| 怀宁县| 措勤县| 南充市| 华安县| 屏边| 南乐县| 武宣县| 襄汾县| 盐城市| 同心县| 澄城县| 舟曲县| 深州市| 吉林省| 遵化市| 石林| 巫山县| 张家界市| 上栗县| 乌苏市| 江孜县| 紫阳县| 巫山县| 黎城县| 和硕县| 遵义县| 浮山县| 平远县| 沛县| 汉沽区| 南江县| 平遥县| 同江市| 桐柏县| 潞西市| 昌黎县| 呼和浩特市| 宁远县| 通渭县| 民乐县|