需要使用到一个类:IFrame,这个类所包含的项目可到Google下载:http://code.google.com/p/flex-iframe/
方法一:在MXML中编辑
注意:需要把下载下来的flex-iframe压缩包中的.swc文件拷贝到Flex项目的libs目录中,否则会报错。
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexiframe="http://code.google.com/p/flex-iframe/"> <flexiframe:IFrame id="googleIFrame" label="Google" source="http://www.google.com" width="80%" height="80%"/> <mx:Application>
方法二:使用ActionScript编辑
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="initApp()"> <fx:Script> import com.flexiframe.IFrame; // 导入IFrame类 public function initApp():void { var myiframe:IFrame = new IFrame(); myiframe.id = "theBaiduSite"; myiframe.label = "百度"; myiframe.source = "http://www.baidu.com/"; myiframe.width = 240; myiframe.height = 300; this.addElement(myiframe); } </fx:Script> </mx:Application>