Flexe2.0 学习笔记一(利用PopUpManager来显示一个简单窗体)

 

None.gif <? xml version = " 1.0 " ?>
None.gif
< mx:Application xmlns:mx = " http://www.adobe.com/2006/mxml "  height = " 600 "  width = " 600 " >
None.gif    
< mx:Script >
None.gif        
<! [CDATA[
None.gif            
import  mx.containers.TitleWindow;
None.gif            
import  flash.events. * ;
None.gif            
import  mx.managers.PopUpManager;
None.gif            
import  mx.controls.Button;
None.gif            
import  mx.core.IFlexDisplayObject;
None.gif            
None.gif            
//  The variable for the TitleWindow container
None.gif
             public  var myTitleWindow:TitleWindow  =   new  TitleWindow();
None.gif
None.gif            
//  Method to instantiate and display a TitleWindow container.
None.gif            
//  This is the initial Button control's click event handler.
ExpandedBlockStart.gifContractedBlock.gif
             public  function openWindow(event:MouseEvent): void   dot.gif {
InBlock.gif                
// Set the TitleWindow container properties.
InBlock.gif
                myTitleWindow = new TitleWindow();
InBlock.gif                myTitleWindow.showCloseButton
=true;
InBlock.gif               
InBlock.gif                myTitleWindow.title 
= "My Window Title";
InBlock.gif                myTitleWindow.width
= 220;
InBlock.gif                myTitleWindow.height
= 150;
InBlock.gif                
InBlock.gif                
// Call the method to add the Button control to the 
InBlock.gif                
// TitleWindow container.
InBlock.gif
                populateWindow();
InBlock.gif                
// Use the PopUpManager to display the TitleWindow container.
InBlock.gif
                PopUpManager.addPopUp(myTitleWindow, thistrue);
ExpandedBlockEnd.gif            }

None.gif        
None.gif            
//  The method to create and add the Button child control to the
None.gif            
//  TitleWindow container.
ExpandedBlockStart.gifContractedBlock.gif
             public  function populateWindow(): void   dot.gif {
InBlock.gif                var btn1:Button 
= new Button();
InBlock.gif                btn1.label
="close";
InBlock.gif                btn1.addEventListener(MouseEvent.CLICK, closeTitleWindow);
InBlock.gif                myTitleWindow.addChild(btn1);    
ExpandedBlockEnd.gif            }

None.gif            
//  The method to close the TitleWindow container.
ExpandedBlockStart.gifContractedBlock.gif
             public  function closeTitleWindow(event:MouseEvent): void   dot.gif {
InBlock.gif                PopUpManager.removePopUp(event.currentTarget.parent);
InBlock.gif                
ExpandedSubBlockStart.gifContractedSubBlock.gif            
private function removeForm():void dot.gif{
InBlock.gif                PopUpManager.removePopUp(helpWindow);
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif        ]]
>
InBlock.gif    
</mx:Script>
InBlock.gif    
<mx:Button label="Open Window" click="openWindow(event)"/>
InBlock.gif
</mx:Application>
InBlock.gif
InBlock.gif
先把代码贴出来,其实是FLEX的帮助文档,但是如何显示一个简单窗体在网上找半天没找到,又不知道该如何使用FLEX的帮助,呵呵.今天在 kenshin的提醒下找到了这个,myTitleWindow.showCloseButton = true ;这个属性是我自己加的,实现了在简单窗体上的关闭按钮,但还不知道如何处理其事件,下次再说吧,先实现这个再说

转载于:https://www.cnblogs.com/forrestsun/articles/471167.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值