Flex中嵌入web页面
需要使用到一个类:IFrame,这个类所包含的项目可到Google下载:http://code.google.com/p/flex-iframe/
方法一:在MXML中编辑
注意:需要把下载下来的flex-iframe压缩包中的.swc文件拷贝到Flex项目的libs目录中,否则会报错。
1 | < mx:Application xmlns:mx = "http://www.adobe.com/2006/mxml" |
2 | xmlns:flexiframe = "http://code.google.com/p/flex-iframe/" > |
3 | < flexiframe:IFrame |
4 | id = "googleIFrame" |
5 | label = "Google" |
6 | source = "http://www.google.com" |
7 | width = "80%" |
8 | height = "80%" /> |
9 | < mx:Application > |
方法二:使用ActionScript编辑
01 | <? xml version = "1.0" encoding = "utf-8" ?> |
02 | < mx:Application xmlns:fx = "http://ns.adobe.com/mxml/2009" |
03 | xmlns:s = "library://ns.adobe.com/flex/spark" |
04 | xmlns:mx = "library://ns.adobe.com/flex/mx" |
05 | applicationComplete = "initApp()" > |
06 | < fx:Script > |
07 | import com.flexiframe.IFrame; // 导入IFrame类 |
08 | |
09 | public function initApp():void |
10 | { |
11 | var myiframe:IFrame = new IFrame(); |
12 | myiframe.id = "theBaiduSite"; |
13 | myiframe.label = "百度"; |
14 | myiframe.source = "http://www.baidu.com/"; |
15 | myiframe.width = 240; |
16 | myiframe.height = 300; |
17 | this.addElement(myiframe); |
18 | } |
19 | </ fx:Script > |
20 | </ mx:Application > |