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

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

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

    Alert,TitleWindow以及PopUp的簡單分析

    這兩天為了Fluorida的closePopUp功能,讀了點Flex框架的源碼,對Alert,TitleWindow以及Flex的PopUp功能做了簡單的分析。
    【Alert和PopUp】
    Alert內部其實是調用了PopUpManager.在parent參數為null或者為Application的時候,彈出的窗口將跟當前Application在一個容器下。Alert在最頂層,Application在最底層,中間那層是一個稱之為modalWindows的控件,其實就是Alert后面那個磨砂的層。為了點到Alert上的按鈕,寫了一個小程序分析Alert的結構,不是很好讀,但是可以運行一下,看看分析出的Alert的內部結構:(大略說一下,Alert的Child有一個AlertForm,而AlertForm的Child除了第一個是TextField以外,都是按鈕)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
        
    <mx:Script>
            
    <![CDATA[
                import mx.core.IChildList;
                import mx.core.UIComponent;
                import mx.core.IFlexDisplayObject;
                import mx.managers.ISystemManager;
                import mx.managers.PopUpManagerChildList;
                import mx.managers.PopUpManager;
                import mx.controls.Alert;
                import mx.events.CloseEvent;
                import mx.core.Singleton;
                import mx.managers.IPopUpManager;
                
                private function showSimpleAlert():void{
                    Alert.okLabel="oKey";
                    Alert.show("Hello, World!","",15,null,alertCloseHandle);
                    var myTimer:Timer = new Timer(1000, 1);
                       myTimer.addEventListener("timer", timerHandler);
                       myTimer.start();            
                }
                
                private function alertCloseHandle(event:CloseEvent):void{
                    simpleAlertShower.label = event.detail.toString();
                }
                
                private function timerHandler(event:TimerEvent):void{
                    var text:String = "elements:";
                    var sm:ISystemManager = (Application.application.root as ISystemManager);
                    text+=sm.numChildren.toString();
                    text+=";\n modalWindows:";
                    text+=sm.numModalWindows.toString();
                    for(var index:int = 0; index < sm.numChildren; index++)
                    {
                        text += "\n" + index + " : ";
                        text += sm.getChildAt(index).toString(); 
                    }
                    
                    var alert:Alert = sm.getChildAt(sm.numChildren - 1) as Alert;
                    text += "\n buttonFlags : "+alert.buttonFlags;
                    text += "\n alertChildren:" + alert.numChildren;
                    for(var index:int = 0; index < alert.numChildren; index++)
                    {
                        text +="\n" + alert.getChildAt(index).toString();
                    }
                    var alertForm:UIComponent = alert.getChildAt(0) as UIComponent;
                    text += "\n alertFormChildren:" + alertForm.numChildren;
                    
                    for(var index:int = 0; index < alertForm.numChildren; index++)
                    {
                        text +="\n"+index+":"+ alertForm.getChildAt(index).toString();
                        
                    }
                    popupChildText.text = text;
                    alertForm.getChildAt(1).dispatchEvent(new MouseEvent(MouseEvent.CLICK));
    //                var popupContainer:IChildList = (application.root as IChildList);
    //                PopUpManager.removePopUp(popupContainer.getChildAt( popupContainer.numChildren - 1 ) as IFlexDisplayObject);

                }
            
    ]]>
        
    </mx:Script>    
          
    <mx:Button id="simpleAlertShower" click="showSimpleAlert();" label="Click Me"/>
          
    <mx:Text id="popupChildText"/>
        
    </mx:Application>
    【關于TitleWindow】
    TitleWindow作為彈出窗口的時候,跟Alert處的位置沒什么區別,我想說的是TitleWindow的closeButton在哪里。下面這個同樣不好讀的程序可以幫助你分析TitleWindow或者說Panel里面都有用什么,以及closeButton在哪,其實就是在rawChildren的最后一個。
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
        
    <mx:Script>
            
    <![CDATA[
                import mx.containers.TitleWindow;
                import mx.core.IChildList;
                import mx.core.UIComponent;
                import mx.core.IFlexDisplayObject;
                import mx.managers.ISystemManager;
                import mx.managers.PopUpManagerChildList;
                import mx.managers.PopUpManager;
                import mx.controls.Alert;
                import mx.events.CloseEvent;
                import mx.core.Singleton;
                import mx.managers.IPopUpManager;
                
                private function showSimpleAlert():void{
                    var popUpWindow:TitleWindow = TitleWindow(PopUpManager.createPopUp(this,TitleWindow,true));
                    popUpWindow.width = 400;
                    popUpWindow.height = 300;
                    popUpWindow.visible = true;
                    popUpWindow.showCloseButton = true;
                    var myTimer:Timer = new Timer(2000, 1);
                       myTimer.addEventListener("timer", timerHandler);
                       myTimer.start();    
                }
                
                private function alertCloseHandle(event:CloseEvent):void{
                    simpleAlertShower.label = event.detail.toString();
                }
                
                private function timerHandler(event:TimerEvent):void{
                    var text:String = "elements:";
                    var sm:ISystemManager = (Application.application.root as ISystemManager);
                    text+=sm.numChildren.toString();
                    text+=";\n modalWindows:";
                    text+=sm.numModalWindows.toString();
                    text+="\n top children: ";
                    for(var index:int = 0; index < sm.numChildren; index++)
                    {
                        text += "\n" + index + " : ";
                        text += sm.getChildAt(index).toString(); 
                    }
                    
                    var titleWindow:TitleWindow = sm.getChildAt(sm.numChildren - 1) as TitleWindow;
                    text += "\n popUpWindowrawChildren:" + titleWindow.rawChildren.numChildren;
                    for(var index:int = 0; index < titleWindow.rawChildren.numChildren; index++)
                    {
                        text +="\n" + titleWindow.rawChildren.getChildAt(index).toString();
                    }
                    var titleBar:UIComponent = (titleWindow.rawChildren.getChildAt(2) as UIComponent);
                    text += " has " + titleBar.numChildren;
                    text += "\n" + titleBar.getChildAt(3).toString();
                    
                    popupChildText.text = text;
    //                var popupContainer:IChildList = (application.root as IChildList);
    //                PopUpManager.removePopUp(popupContainer.getChildAt( popupContainer.numChildren - 1 ) as IFlexDisplayObject);
                    PopUpManager.removePopUp(titleWindow);
                }
            
    ]]>
        
    </mx:Script>    
          
    <mx:Button id="simpleAlertShower" click="showSimpleAlert();" label="Click Me"/>
          
    <mx:Text id="popupChildText"/>
        
    </mx:Application>




    posted on 2008-03-17 00:22 咖啡屋的鼠標 閱讀(2518) 評論(0)  編輯  收藏 所屬分類: Flex

    <2008年3月>
    2425262728291
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    導航

    統計

    常用鏈接

    留言簿(15)

    隨筆分類(52)

    隨筆檔案(76)

    文章分類(3)

    文章檔案(4)

    新聞檔案(1)

    收藏夾

    Flex

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 四虎影视永久免费视频观看| 亚洲精品国产肉丝袜久久| 亚洲另类春色国产精品| 一级毛片在线免费视频| 国产精品成人免费视频网站京东| 亚洲色欲色欲www在线丝| 亚洲高清毛片一区二区| 91精品啪在线观看国产线免费| 亚洲一级黄色视频| 亚洲日韩中文字幕无码一区| 久久不见久久见免费视频7| 亚洲无码精品浪潮| 亚洲AV无码片一区二区三区| 免费在线观看视频网站| 亚洲第一AAAAA片| 久99久无码精品视频免费播放| 国产精品久久香蕉免费播放| 亚洲国产成人综合| 未满十八18禁止免费无码网站| 91麻豆国产自产在线观看亚洲| 亚洲AV无码片一区二区三区| 日韩精品无码区免费专区| 亚洲一卡2卡三卡4卡有限公司| 中文字幕永久免费视频| 亚洲高清国产拍精品青青草原| 亚洲精品国产摄像头| 国产在线观看片a免费观看| 1区1区3区4区产品亚洲| 男女午夜24式免费视频 | 国产网站在线免费观看| 亚洲午夜精品在线| 最近中文字幕mv免费高清在线| 国产亚洲精品a在线观看app| 国产精品视频全国免费观看| 亚洲不卡无码av中文字幕| 国产精品亚洲а∨无码播放麻豆 | 精品女同一区二区三区免费播放| 夫妻免费无码V看片| 中国亚洲呦女专区| 久久久www成人免费毛片| 2020年亚洲天天爽天天噜|