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

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

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

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

    MXML 文件中實現 ActionScript 邏輯的幾種方法:
    最簡單的方法,在一個 MXML 文件中通過組件的事件直接書寫簡單的邏輯控制,但是并不推薦。

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

    2. < mx : Panel ? title = 'My ? Application' ? > ?

    3. < mx : HBox > ?

    4. < mx : Label ? text = 'Temperature ? in ? Farenheit:' /> ?

    5. < mx : TextInput ? id = 'farenheit' ? width = '120' /> ?

    6. < mx : Button ? label = 'Convert' ? click = 'celsius.text=(farenheit.text-32)/1.8;' ? /> ?

    7. < mx : Label ? text = 'Temperature ? in ? Celsius:' /> ?

    8. < mx : Label ? id = 'celsius' ? width = '120' ? fontSize = '48' /> ?

    9. </ mx : HBox >

    10.? </ mx : Panel >

    11.? </ mx : Application >


    第二種,在 MXML 文件中定義函數調用,比較適合簡單的應用,如

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

    2. < mx : Script > ?

    3. <![ CDATA [ ?

    4. function ? calculate () ? { ? ?

    5. celsius . text =( farenheit . text - 32 )/ 1.8 ; ?

    6. ? } ?

    7. ]]> ?

    8. </ mx : Script >
    ?

    9. < mx : Panel ? title = 'My ? Application' ? >

    10.? < mx : HBox >

    11.? < mx : Label ? text = 'Temperature ? in ? Farenheit:' />

    12.? < mx : TextInput ? id = 'farenheit' ? width = '120' />

    13.? < mx : Button ? label = 'Convert' ? click = 'calculate();' ? />

    14.? < mx : Label ? text = 'Temperature ? in ? Celsius:' />

    15.? < mx : Label ? id = 'celsius' ? width = '120' ? fontSize = '48' />

    16.? </ mx : HBox >

    17.? </ mx : Panel >

    18.? </ mx : Application >



    第三種,把 MXML 文件和腳本文件分開,便于項目管理

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

    2. <!-- ? Specify ? the ? ActionScript ? file ? containing ? the ? function. ? --> ?

    3. < mx : Script ? source = 'sample3script.as' /> ?

    4. < mx : Panel ? title = 'My ? Application' ? > ?

    5. < mx : HBox > ?

    6. < mx : Label ? text = 'Temperature ? in ? Farenheit:' /> ?

    7. < mx : TextInput ? id = 'farenheit' ? width = '120' /> ?

    8. < mx : Button ? label = 'Convert' ? click = 'calculate();' ? /> ?

    9. < mx : Label ? text = 'Temperature ? in ? Celsius:' />

    10.? < mx : Label ? id = 'celsius' ? width = '120' ? fontSize = '48' />

    11.? </ mx : HBox >

    12.? </ mx : Panel >

    13.? </ mx : Application >


    sample.as
    文件代碼如下
    function ? calculate () ? { ?

    2. celsius . text =( farenheit . text - 32 )/ 1.8 ;
    3. ? }


    第四種,使用 MXML 組件方式,更好的封裝實現。下面的例子定義了一個 tempConverter 組件

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

    2. initialize = 'converter.setupListener()' > ?

    3. < local : TempConverter ? id = 'converter' ? xmlns : local = '*' /> ?

    4. < mx : Panel ? title = 'My ? Application' ? > ?

    5. < mx : HBox > ?

    6. < mx : Label ? text = 'Temperature ? in ? Farenheit:' ? /> ?

    7. < mx : TextInput ? id = 'farenheit' ? width = '120' ? /> ?

    8. < mx : Button ? id = 'myButton' ? label = 'Convert' ? /> ?

    9. < mx : Label ? text = 'Temperature ? in ? Celsius:' ? />

    10.? < mx : Label ? id = 'celsius' ? width = '120' ? fontSize = '24' ? />

    11.? </ mx : HBox >

    12.? </ mx : Panel >

    13.? </ mx : Application >

    TempConverter.as 文件代碼如下:

    ?

    1. class ? TempConverter ? implements ? mx . core . MXMLObject { ? ?

    2. public ? var ? view ; ?

    3. function ? initialized ( doc ? : ? Object , ? id ? : ? String ) ? : ? Void ? { ? ?

    4. view ? = ? doc ; ?

    5. ? } ?

    6. function ? setupListener () ? : ? Void ? { ? ?

    7. view . myButton . addEventListener ( 'click' , ? this ); ?

    8. ? } ?

    9. function ? click ( event ) ? { ?

    10.? view . celsius . text =( view . farenheit . text - 32 )/ 1.8 ;

    11.? ? }

    12.? ? }

    posted on 2007-01-12 12:01 ???MengChuChen 閱讀(288) 評論(0)  編輯  收藏 所屬分類: flex2.0
    主站蜘蛛池模板: 亚洲国产精品无码久久久| 成人午夜亚洲精品无码网站| 亚洲手机中文字幕| 99久久免费精品视频| 精品亚洲麻豆1区2区3区| 95免费观看体验区视频| 亚洲综合色丁香麻豆| 性短视频在线观看免费不卡流畅| 亚洲综合一区二区精品久久| 91人人区免费区人人| 亚洲经典在线中文字幕| 免费精品国产日韩热久久| tom影院亚洲国产一区二区| 成年网站免费视频A在线双飞| 亚洲中字慕日产2020| 麻豆国产精品入口免费观看| 亚洲精品无码久久久久YW| 全部免费毛片免费播放| 人人公开免费超级碰碰碰视频 | 亚洲女人被黑人巨大进入| 美女黄频a美女大全免费皮| 国产成人综合亚洲亚洲国产第一页| 中文字幕a∨在线乱码免费看| 无码乱人伦一区二区亚洲| 免费国产作爱视频网站| 国产精品成人亚洲| 自拍偷自拍亚洲精品情侣| 24小时日本电影免费看| 亚洲色成人网站WWW永久四虎| 亚洲精品无码久久不卡| 99久久免费中文字幕精品| 亚洲中文字幕乱码一区| 国产成人亚洲影院在线观看| 久久一区二区三区免费播放| 亚洲中文字幕无码mv| 亚洲精品高清无码视频| 国产一卡2卡3卡4卡无卡免费视频 国产一卡二卡3卡四卡免费 | 亚洲色大成网站WWW久久九九| 8x网站免费入口在线观看| 苍井空亚洲精品AA片在线播放| 国产亚洲日韩在线三区|