RSS订阅优然探索
你的位置:首页 » Flex » 正文

弹出窗口的显示和位置PopUpManager

选择字号: 超大 标准 发布时间:2010-2-19 8:49:30 | 作者:admin | 0个评论 | 人浏览

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas horizontalCenter="0" verticalCenter="0">
 <mx:LinkButton label="Top" x="100" y="10" click="showDetail(event)"/>
 <mx:LinkButton label="Left" x="10" y="100" click="showDetail(event)"/>
 <mx:LinkButton label="Bottom" x="100" y="200" click="showDetail(event)"/>
 <mx:LinkButton label="Right" x="200" y="100" click="showDetail(event)"/>
 <mx:Canvas width="100" height="100" x="125" y="40" backgroundColor="#ff0000" rotation="45" />
</mx:Canvas>

<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;

private const POPUP_OFFSET:int = 10;

private function showDetail(evt:MouseEvent):void {
 // create the popup
 var popup:CustomPopUp = CustomPopUp(PopUpManager.createPopUp(this,CustomPopUp,false));
 popup.message = "This is the detail for " +evt.target.label;
 // position the popup
 var pt:Point = new Point(0, 0);
 pt = evt.target.localToGlobal(pt);
 popup.x = pt.x + POPUP_OFFSET;
 popup.y = pt.y + evt.target.height + POPUP_OFFSET;
}

]]>
</mx:Script>
</mx:Application>

 

 

CustomPopUp.mxml

 

<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="300" height="50" styleName="customPopUp" showCloseButton="true" close="handleClose(event)">
<mx:Style>
.customPopUp {
 header-height:2;
 padding-left:5;
 padding-right:5;
 padding-top:5;
 padding-bottom:5;
 border-color:#000000;
 border-alpha:.5;
 border-thickness-left:5;
 border-thickness-right:5;
 border-thickness-bottom:5;
 border-thickness-top:5;
 background-color:#666666;
 color:#ffffff;
}
</mx:Style>

<mx:Text width="100%" height="100%" text="{message}"/>

<mx:Script>
<![CDATA[
 import mx.managers.PopUpManager;
 import mx.events.CloseEvent;
 
 [Bindable]
 public var message:String;
 
 private function handleClose(evt:CloseEvent):void {
  PopUpManager.removePopUp(this);
 }
]]>
</mx:Script>
</mx:TitleWindow>

 

标签:弹出窗口的显示和位置PopUpManager  

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。