<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    【永恒的瞬間】
    ?Give me hapy ?

    存儲和驗(yàn)證數(shù)據(jù)
    你可以使用數(shù)據(jù)模型來存儲特定數(shù)據(jù),數(shù)據(jù)模型是一個可以提供存儲數(shù)據(jù)屬性和包含附加方法的 AS 對象。申明一個簡單的沒有任何方法的數(shù)據(jù)模型可以使用 <mx:Model> <mx:XML> 標(biāo)記,你還可以使用驗(yàn)證組件驗(yàn)證存儲數(shù)據(jù)的有效性。 Flex 包含了一套標(biāo)準(zhǔn)的數(shù)據(jù)驗(yàn)證組件,當(dāng)然你也可以創(chuàng)建自己的驗(yàn)證組件。
    下面的例子顯示了一個簡單的數(shù)據(jù)驗(yàn)證。

    1. < mx : Application ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' ? > ?

    2. < mx : Panel ? title = 'My ? Application' ? marginTop = '10' ? marginBottom = '10' ?

    3. marginLeft = '10' ? marginRight = '10' ? > ?

    4. < mx : TextInput ? id = 'homePhoneInput' ? text = '這不是一個有效的電話號碼' /> ?

    5. < mx : TextInput ? id = 'cellPhoneInput' ? text = '(999)999-999' />

    6. < mx : TextInput ? id = 'emailInput' ? text = 'me@somewhere.net' />

    7. </ mx : Panel >
    ?

    8. < mx : Model ? id = 'contact' > ?

    9. < homePhone >{ ? homePhoneInput . text ? }</ homePhone >

    10.? < cellPhone >{ ? cellPhoneInput . text ? }</ cellPhone >

    11.? < email >{ ? emailInput . text ? }</ email >

    12.? </ mx : Model >

    13.? < mx : PhoneNumberValidator ? field = 'contact.homePhone' />

    14.? < mx : PhoneNumberValidator ? field = 'contact.cellPhone' />

    15.? < mx : EmailValidator ? field = 'contact.email' />

    16.? </ mx : Application >

    格式化數(shù)據(jù)
    除了進(jìn)行數(shù)據(jù)驗(yàn)證之外,格式化輸入的數(shù)據(jù)也是經(jīng)常需要用到的。
    Flex 一樣包含了一套用于數(shù)據(jù)格式化的組件,下面的例子對郵編進(jìn)行格式化處理:

    1. < mx : Application ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' >
    2. < mx : ZipCodeFormatter ? id = 'ZipCodeDisplay' ? formatString = '#####-####' ? />

    3 < mx : Script >
    4. <![ CDATA [
    5. var ? storedZipCode = 123456789 ;
    6. ]]>
    7. </ mx : Script >

    8. < mx : Panel ? title = 'My ? Application' ? marginTop = '10' ? marginBottom = '10' ? marginLeft = '10' ? marginRight = '10' ? >
    9. < mx : TextInput ? text = '' ? />
    10.? </ mx : Panel >

    11.? </ mx : Application >


    常用的數(shù)據(jù)格式化還有對日期的格式化處理:

    : NumberFormatter 數(shù)字格式化
    2 : CurrencyFormatter 貨幣格式化
    3 : PhoneFormatter 電話號碼格式化
    4 : ZipCodeFormatter 郵編格式化
    5 : DateFormatter 日期格式化
    6 : SwitchSymbolFormatter 創(chuàng)建自定義格式


    使用樣式表
    還可以使用 <mx:Style> 標(biāo)記表來定義 Flex 組件的樣式表。

    1. < mx : Application ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' >

    2. < mx : Style >

    3. . myclass ? { ?? color : ? Red ?? } ? /* ? class ? selector ? */

    4. Button ? { ?? font - size : ? 18pt ? } ? /* ? type ? selector ? */

    5. </ mx : Style >
    ?

    6. < mx : Panel ? title = 'My ? Application' ? marginTop = '10' ? marginBottom = '10'

    7. marginLeft = '10' ? marginRight = '10' ? >

    8. < mx : Button ? styleName = 'myclass' ? label = 'This ? is ? red ? 18 ? point ? text.' />

    9. </ mx : Panel >

    10.? </ mx : Application >

    ?


    使用效果
    可以對組件使用過渡效果,效果往往是在事件觸發(fā)后產(chǎn)生,如鼠標(biāo)單擊、組件失去焦點(diǎn)和組件消失等。 Flex 專門提供了一套內(nèi)置的效果組件。下面看一個例子:

    < mx : Application ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' >?????
    <mx:Panel?title='My?Application'?marginTop='10'?marginBottom='10'?marginLeft='10'?marginRight='10'?>

    3. < mx : Button ? id = 'myButton' ? mouseOverEffect = 'Zoom' ? />

    4. </ mx : Panel >

    5. </ mx : Application >



    使用 MXML 組件
    可以使用 MXML 文件定義自己的組件或者定義已有組件的組合,并通過 <local: 自定義組件名 /> 的方式調(diào)用。

    ? 1. <!-- ? MyComboBox . mxml ? -->
    ? 2. < mx : VBox ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' >
    ? 3. < mx : ComboBox ? >
    ? 4. < mx : dataProvider >

    ? 5. < mx :Array>
    ? 6. < mx : String > Dogs </ mx : String >
    ? 7. < mx : String > Cats </ mx : String >
    ? 8. < mx : String > Mice </ mx : String >
    ? 9. </ mx :Array>

    .? </ mx : dataProvider >
    11.? </ mx : ComboBox >
    12.? </ mx : VBox >


    注意, MXML 組件文件并不需要 <mx:Application> 標(biāo)記,更復(fù)雜的自定義組件可以使用 JSP 或其它語言動態(tài)生成。
    調(diào)用自定義組件的應(yīng)用程序文件格式如下:

    <!-- ? MyApplication . mxml ? -->

    2. < mx : Application ? xmlns : mx = 'http://www.macromedia.com/2003/mxml' ? xmlns : local = '*' >

    3. < mx : Panel ? title = 'My ? Application' ? marginTop = '10' ? marginBottom = '10' ? marginLeft = '10' ? marginRight = '10' ? >

    4. <!-- ? 調(diào)用MyComboBox組件 ? -->

    5. < local : MyComboBox />

    6. </ mx : Panel >

    7. </ mx : Application >

    posted on 2007-01-12 11:45 ???MengChuChen 閱讀(168) 評論(0)  編輯  收藏 所屬分類: flex2.0
    主站蜘蛛池模板: 四虎免费影院ww4164h| 亚洲麻豆精品国偷自产在线91| 亚洲AV伊人久久青青草原| 亚洲av片一区二区三区| 亚洲色偷偷综合亚洲AVYP| 视频一区在线免费观看| 午夜视频免费观看| 成人亚洲国产va天堂| 日本亚洲中午字幕乱码| 免免费国产AAAAA片| 亚洲片国产一区一级在线观看| 亚洲精品无码久久千人斩| caoporm碰最新免费公开视频| 国产一区二区三区在线免费观看| 亚洲国产精品自在自线观看| 嫩草影院在线播放www免费观看| 亚洲乳大丰满中文字幕| 无码日韩精品一区二区免费暖暖| 亚洲AV午夜福利精品一区二区| 性无码免费一区二区三区在线| 蜜臀98精品国产免费观看| 亚洲高清中文字幕| 国产a视频精品免费观看| 亚洲色偷偷偷综合网| 国产成人综合久久精品免费| 人体大胆做受免费视频| 亚洲AV无码一区二区乱子伦| 中文字幕亚洲免费无线观看日本| 亚洲熟妇丰满xxxxx| 亚洲精品天堂成人片?V在线播放| 特级做A爰片毛片免费看无码 | 中中文字幕亚洲无线码| 日韩精品免费电影| 国产精品极品美女自在线观看免费| 免费观看的毛片大全| 国产成人精品久久亚洲高清不卡| 亚洲午夜av影院| 爱情岛论坛免费视频| 午夜影视日本亚洲欧洲精品一区| yellow免费网站| 亚洲第一二三四区|