将 html 页面 或 jsp 页面嵌入 到flex 页面中
step1:下载 flex-iframe-1.5.1.swc
http://code.google.com/p/flex-iframe/
step2:将此文件拷贝到flex项目的flex_libs文件夹下
step3:创建mxml文件 vboxiframe.mxml
Java代码
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:code="http://code.google.com/p/flex-iframe/" width="100%" height="100%">
<mx:HDividedBox x="0" y="10" width="100%" height="100%">
<mx:Panel width="30%" height="100%" layout="absolute">
<code:IFrame id="frm2" source="Demo/WebContent/topology.html" height="100%" width="100%"/>
</mx:Panel>
<mx:Panel width="70%" height="100%" layout="absolute">
<code:IFrame id="frm1" source="Demo/WebContent/topology.html" height="100%" width="100%"/>
</mx:Panel>
</mx:HDividedBox>
</mx:VBox>
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:code="http://code.google.com/p/flex-iframe/" width="100%" height="100%">
<mx:HDividedBox x="0" y="10" width="100%" height="100%">
<mx:Panel width="30%" height="100%" layout="absolute">
<code:IFrame id="frm2" source="Demo/WebContent/topology.html" height="100%" width="100%"/>
</mx:Panel>
<mx:Panel width="70%" height="100%" layout="absolute">
<code:IFrame id="frm1" source="Demo/WebContent/topology.html" height="100%" width="100%"/>
</mx:Panel>
</mx:HDividedBox>
</mx:VBox>
运行该 application 即可看到 此 mxml中嵌入 topology.htm 内容
但是有一个问题,如果我想 嵌入 “www.google.com”则运行出来说找不到 此 页面
problem1:如果我将 source=“www.google.com”则自动会加上我的项目名称eg smp31/www.google.com.cn
problem2:如果我将 source=“/www.google.com”则 直接报错找不到/www.google.com页面文件
希望哪位帮忙指点下我应该 怎么 嵌入一个 公网上的 hmtml 页!非常感谢!!!
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
WAY2在mxml文件中嵌入一个其他项目中的swf文件
在mxml文件中直接复制下面代码,更改 swf 路径就可
Java代码
<mx:Script>
<![CDATA[
import gs.plugins.VolumePlugin;
import mx.events.FlexEvent;
import mx.controls.SWFLoader;
import mx.managers.SystemManager;
private function init():void
{
var loader:SWFLoader = new SWFLoader();
loader.percentHeight = 100;
loader.percentWidth = 100;
loader.addEventListener(Event.COMPLETE, onLoaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
//loader.load("Demo/WebContent/topology.swf");
//smp31.swf
//D:\develop\develop_WorkSpace\liferaySmp31\smp31\WebContent\Demo\WebContent\topology.swf
// loader.load("D:\develop\develop_WorkSpace\liferaySmp31\smp31\WebContent\Demo\WebContent\topology.swf");
addChild(loader);
}
private function onError(e:Error):void{
}
private function onLoaded(e:Event):void
{
var loader:SWFLoader = e.target as SWFLoader;
var sysMgr:SystemManager = loader.content as SystemManager;
sysMgr.addEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete);
}
private function onAppComplete(e:FlexEvent):void
{
var sysMgr:SystemManager = e.target as SystemManager;
//如果此页面是application就转成application如果是 module 就转成 module
// var app:Application = sysMgr.getChildAt(0) as Application;
var app:Module = sysMgr.getChildAt(0) as Module;
//app.callAPI(parameters);
}
]]>
</mx:Script>
<mx:Script>
<![CDATA[
import gs.plugins.VolumePlugin;
import mx.events.FlexEvent;
import mx.controls.SWFLoader;
import mx.managers.SystemManager;
private function init():void
{
var loader:SWFLoader = new SWFLoader();
loader.percentHeight = 100;
loader.percentWidth = 100;
loader.addEventListener(Event.COMPLETE, onLoaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
//loader.load("Demo/WebContent/topology.swf");
//smp31.swf
//D:\develop\develop_WorkSpace\liferaySmp31\smp31\WebContent\Demo\WebContent\topology.swf
// loader.load("D:\develop\develop_WorkSpace\liferaySmp31\smp31\WebContent\Demo\WebContent\topology.swf");
addChild(loader);
}
private function onError(e:Error):void{
}
private function onLoaded(e:Event):void
{
var loader:SWFLoader = e.target as SWFLoader;
var sysMgr:SystemManager = loader.content as SystemManager;
sysMgr.addEventListener(FlexEvent.APPLICATION_COMPLETE, onAppComplete);
}
private function onAppComplete(e:FlexEvent):void
{
var sysMgr:SystemManager = e.target as SystemManager;
//如果此页面是application就转成application如果是 module 就转成 module
// var app:Application = sysMgr.getChildAt(0) as Application;
var app:Module = sysMgr.getChildAt(0) as Module;
//app.callAPI(parameters);
}
]]>
</mx:Script>
用标签方式也可直接嵌入swf文件,时间仓促 没来的急 研究 这两种 方式有什么区别
Java代码
<mx:VBox width="100%" height="100%">
<mx:SWFLoader source="http://localhost:8080/topology/topology.swf" width="100%" height="100%"/>
</mx:VBox>