发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
<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>
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。