<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

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲Av永久无码精品三区在线 | 蜜臀亚洲AV无码精品国产午夜.| 午夜一级免费视频| 国产精品hd免费观看| 亚洲视频一区调教| 在线观看免费a∨网站| 香港经典a毛片免费观看看| 亚洲国产一成人久久精品| 免费成人福利视频| free哆拍拍免费永久视频| 久久久久亚洲av无码专区喷水| 成全视频免费高清| 国产偷伦视频免费观看| 色偷偷尼玛图亚洲综合| 国产亚洲精品va在线| 国产免费观看黄AV片| 97在线视频免费播放| 一本岛v免费不卡一二三区| 亚洲国产av一区二区三区丶| 久久久久噜噜噜亚洲熟女综合 | 在线观看午夜亚洲一区| 日韩成全视频观看免费观看高清| 久别的草原电视剧免费观看| 美女尿口扒开图片免费| 亚洲综合丁香婷婷六月香| 亚洲AV成人无码久久精品老人 | 色se01短视频永久免费| 黄色网站软件app在线观看免费| 婷婷亚洲综合五月天小说在线| 亚洲毛片基地日韩毛片基地| 亚洲AV综合色一区二区三区| 在线观看免费成人| 日本免费高清视频| 亚洲AV无码片一区二区三区| 亚洲国产片在线观看| 亚洲一区无码中文字幕乱码| 久久久久亚洲精品日久生情| 精品亚洲aⅴ在线观看| 亚洲av激情无码专区在线播放 | 日韩精品免费一级视频| 国产大片91精品免费观看不卡|