(1)基本的弹出窗口
<?xml version="1.0" encoding="utf-8"?>
<!---
Pop-up component used to render HTML text.
-->
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:iframe="http://code.google.com/p/flex-iframe/"
width="100%" height="100%"
cornerRadius="10"
creationComplete="htmlPopup_creationCompleteHandler(event)">
<s:filters>
<s:GlowFilter alpha="0.8"
blurX="50"
blurY="50"
color="0xFFFFFF"
quality="{BitmapFilterQuality.MEDIUM}"
strength="1"/>
</s:filters>
<fx:Script>
<![CDATA[
import flash.filters.BitmapFilterQuality;
import flashx.textLayout.conversion.TextConverter;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
[Bindable]
public var btnLabel:String = "OK";
[Bindable]
public var source:String = "www.baidu.com";
[Bindable]
public var txtareaWidth:Number = 500;
[Bindable]
public var txtareaHeight:Number = 500;
public static function show(content:String = "",
btnLabel:String = "OK",
width:Number = 500,
height:Number = 500,
modal:Boolean = true,
closeHandler:Function = null):FramePopup
{
var alert:FramePopup = new FramePopup();
var parent:Sprite = Sprite(FlexGlobals.topLevelApplication);
if (closeHandler != null)
{
alert.addEventListener(CloseEvent.CLOSE,closeHandler);
}
alert.source = content;
alert.btnLabel = btnLabel;
alert.txtareaWidth = width;
alert.txtareaHeight = height;
FramePopupManager.addPopUp(alert,parent,modal);
return alert;
}
private function close(event:Event):void
{
FramePopupManager.removePopUp(this);
dispatchEvent(new CloseEvent(CloseEvent.CLOSE));
}
protected function htmlPopup_creationCompleteHandler(event:FlexEvent):void
{
setStyle("backgroundColor",getStyle("contentBackgroundColor"));
setStyle("backgroundAlpha",FlexGlobals.topLevelApplication.getStyle("backgroundAlpha"));
}
]]>
</fx:Script>
<!-- doc reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/conversion/TextConverter.html#TEXT_FIELD_HTML_FORMAT -->
<s:RectangularDropShadow id="dropShadow"
left="0" right="0" top="0" bottom="0"
alpha="0.32"
angle="90"
blRadius="10"
blurX="20"
blurY="20"
brRadius="10"
distance="25"/>
<s:VGroup horizontalAlign="center" paddingBottom="10">
<s:Button click="close(event)" label="{btnLabel}"/>
<iframe:IFrame width="{txtareaWidth}" height="{txtareaHeight}" source="{source}" >
</iframe:IFrame>
</s:VGroup>
</s:BorderContainer>
---------------------------------------------------------------------------------------------
package com.esri.viewer.components
{
import flash.display.displayObject;
import flash.display.displayObjectContainer;
import mx.core.IFlexdisplayObject;
import mx.managers.PopUpManager;
/**
* Manager class used to control HTML pop-up component location and content.
*/
public class FramePopupManager
{
public static function addPopUp(window:IFlexdisplayObject,
parent:displayObject,
modal:Boolean = false,
childList:String = null):void
{
PopUpManager.addPopUp(window,modal,childList);
showSplash(window,parent as displayObjectContainer);
}
private static function showSplash(window:IFlexdisplayObject,parent:displayObjectContainer):void
{
var x:Number = parent.width - window.width-32;
var y:Number = (parent.height - window.height) / 2;
window.move(Math.ceil(x),Math.ceil(y));
}
public static function removePopUp(window:IFlexdisplayObject):void
{
PopUpManager.removePopUp(window);
}
}
}
调用:FramePopup.show("http://www.baidu.com","ok",200,200);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。