<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 咖啡屋的鼠標 閱讀(2516) 評論(0)  編輯  收藏 所屬分類: Flex

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

    導航

    統計

    常用鏈接

    留言簿(15)

    隨筆分類(52)

    隨筆檔案(76)

    文章分類(3)

    文章檔案(4)

    新聞檔案(1)

    收藏夾

    Flex

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 2017亚洲男人天堂一| 怡红院亚洲怡红院首页| 亚洲欧洲日韩在线电影| 99久热只有精品视频免费观看17| 在线A亚洲老鸭窝天堂| av片在线观看永久免费| 久久久久久亚洲精品不卡| 深夜福利在线视频免费| 亚洲精品一级无码中文字幕| 国产精品1024在线永久免费| 在线亚洲午夜理论AV大片| 免费播放一区二区三区| 亚洲欧洲日产国码www| 好先生在线观看免费播放| 亚洲爆乳精品无码一区二区| 日韩毛片无码永久免费看| 男女交性无遮挡免费视频| 国产亚洲成归v人片在线观看| 黄色网站软件app在线观看免费 | 2022久久国产精品免费热麻豆| 亚洲精品欧洲精品| 国产一精品一AV一免费孕妇| 99亚洲乱人伦aⅴ精品| 亚洲第一区在线观看| 国产精品免费无遮挡无码永久视频| 亚洲黄色免费观看| 成人网站免费观看| 一个人看的www免费在线视频| 亚洲AV综合色区无码另类小说| 18级成人毛片免费观看| 男男gay做爽爽免费视频| 亚洲成AV人片在WWW色猫咪| 最近中文字幕高清免费中文字幕mv| 亚洲中文字幕无码亚洲成A人片| 亚洲国产成人精品女人久久久| 男人的天堂网免费网站| 亚洲精华国产精华精华液网站 | 日韩精品一区二区亚洲AV观看| 最近的免费中文字幕视频| 国产99久久久久久免费看| 亚洲影视一区二区|