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

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

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

    隨筆 - 8  文章 - 55  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    朋友的Blog

    最新評論

    閱讀排行榜

    評論排行榜

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

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

    <mx:Panel title='My Application' >

    <mx:HBox>

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

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

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

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

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

    </mx:HBox>
    </mx:Panel>
    </mx:Application>

    第二種,在MXML文件中定義函數(shù)調(diào)用,比較適合簡單的應(yīng)用,如

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

    <mx:Script>

    <![CDATA[

    function calculate() {

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

    }

    ]]>

    </mx:Script>

    <mx:Panel title='My Application' >
    <mx:HBox>
    <mx:Label text='Temperature in Farenheit:'/>
    <mx:TextInput id='farenheit' width='120'/>
    <mx:Button label='Convert' click='calculate();' />
    <mx:Label text='Temperature in Celsius:'/>
    <mx:Label id='celsius' width='120' fontSize='48'/>
    </mx:HBox>
    </mx:Panel>
    </mx:Application>

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

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

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

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

    <mx:Panel title='My Application' >

    <mx:HBox>

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

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

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

    <mx:Label text='Temperature in Celsius:'/>
    <mx:Label id='celsius' width='120' fontSize='48'/>
    </mx:HBox>
    </mx:Panel>
    </mx:Application>

    sample.as文件代碼如下:
    function calculate() {
    celsius.text=(farenheit.text-32)/1.8;
    }

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

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

    initialize='converter.setupListener()'>

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

    <mx:Panel title='My Application' >

    <mx:HBox>

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

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

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

    <mx:Label text='Temperature in Celsius:' />
    <mx:Label id='celsius' width='120' fontSize='24' />
    </mx:HBox>
    </mx:Panel>
    </mx:Application>

    TempConverter.as文件代碼如下:

    class TempConverter implements mx.core.MXMLObject{

    public var view;

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

    view = doc;

    }

    function setupListener() : Void {

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

    }

    function click(event) {
    view.celsius.text=(view.farenheit.text-32)/1.8;
    }
    }
    posted on 2006-04-29 13:40 blog搬家了--[www.ialway.com/blog] 閱讀(308) 評論(0)  編輯  收藏 所屬分類: Flex
    主站蜘蛛池模板: 免费人成视频在线| 最近2019中文免费字幕| 亚洲第一黄片大全| 日韩毛片一区视频免费| 亚洲AV之男人的天堂| 乱淫片免费影院观看| 国产亚洲美女精品久久久| 老司机午夜在线视频免费| www国产亚洲精品久久久日本| 老司机午夜性生免费福利 | 成年女人18级毛片毛片免费| 亚洲中文字幕久久无码| 日韩在线天堂免费观看| 国产精品亚洲va在线观看| 亚洲午夜激情视频| 青青草原1769久久免费播放| 久久久亚洲AV波多野结衣| 手机在线毛片免费播放| 国产精品亚洲综合网站| 亚洲中文字幕久久精品无码喷水| 久久青青草原国产精品免费| 亚洲日本在线播放| 国产成人精品123区免费视频| 成人午夜免费视频| 亚洲一区影音先锋色资源| 午夜dj在线观看免费视频| www免费黄色网| 亚洲综合激情六月婷婷在线观看| 成人毛片手机版免费看| 国产大片免费天天看| 亚洲熟妇无码爱v在线观看| 国产免费看插插插视频| 久久99精品视免费看| 亚洲欧洲无卡二区视頻| 亚洲无线观看国产精品| 国产成人无码免费看视频软件| 青青视频免费在线| 亚洲成人动漫在线| 国产极品粉嫩泬免费观看 | 国产一区二区三区免费看| 中文字幕免费不卡二区|