Apache flex 如何在FlexUI组件中显示远程swf?
我试图在我的flex应用程序中显示远程swf,我能够加载swf,但它在我的flex应用程序中没有显示(visble) 这是密码Apache flex 如何在FlexUI组件中显示远程swf?,apache-flex,air,flex4.5,Apache Flex,Air,Flex4.5,我试图在我的flex应用程序中显示远程swf,我能够加载swf,但它在我的flex应用程序中没有显示(visble) 这是密码 private function onLoaderComplete(event:Event):void{ can.addChild(l); } import flash.system.SecurityDomain; import flash.system.ApplicationD
private function onLoaderComplete(event:Event):void{
can.addChild(l);
}
import flash.system.SecurityDomain;
import flash.system.ApplicationDomain;
var l:Loader = new Loader();
private function initApp():void {
var context:LoaderContext = new LoaderContext();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
if(Security.sandboxType == Security.REMOTE){
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
l.load(new URLRequest('www.somedomain.com/load.swf?id1'), context);
}else{
l.load(new URLRequest('www.somedomain.com/load.swf?id=1'));
}
private function onLoaderComplete(event:Event):void{
can.addChild(l);
}
<mx:Canvas width="100%" height="50%" backgroundColor="red">
<mx:UIComponent id="can" width="100%" height="100%" >
</mx:UIComponent>
</mx:Canvas>
专用函数onLoaderComplete(事件:事件):无效{
can.addChild(l);
}
导入flash.system.SecurityDomain;
导入flash.system.ApplicationDomain;
var l:Loader=new Loader();
私有函数initApp():void{
变量上下文:LoaderContext=new LoaderContext();
l、 contentLoaderInfo.addEventListener(Event.COMPLETE、onLoaderComplete);
if(Security.sandboxType==Security.REMOTE){
变量上下文:LoaderContext=new LoaderContext();
context.securityDomain=securityDomain.currentDomain;
l、 load(新的URL请求('www.somedomain.com/load.swf?id1'),上下文);
}否则{
l、 加载(新的URL请求('www.somedomain.com/load.swf?id=1');
}
专用函数onLoaderComplete(事件:事件):无效{
can.addChild(l);
}
有什么想法吗
谢谢大家您的代码片段没有定义“L”是什么 当前代码中最可能出现的问题是,您正在将“l”添加到UIComponent上,而UIComponent没有用于调整其子级大小和位置的内置代码,因此您的“l”将没有高度和宽度,有效地使其不可见
我会使用a加载另一个SWF文件,并将其显示为应用程序的一部分。l是类型为loader的变量。我尝试了SWFLoader,但没有成功。我已经用您编辑的代码编辑了有问题的代码;您仍然没有调整加载程序的大小;因此,我猜它没有高度或宽度。您确定要加载的SWF有问题吗播放?你能直接在浏览器中加载SWF并查看内容吗?你确定SWF正在加载吗?onLoderComplete方法是否实际触发?如果你为其他事件(如IO错误或HTTP状态)添加侦听器会怎么样?我可以在浏览器中访问SWF。onLoaderComplete事件触发。加载时我没有看到任何错误事件。这很奇怪。di你检查你的远程swf吗?contentloaderinfo维度怎么说?宽度和高度都是零。但是在获得数据后,我的意思是一旦swf加载,宽度和高度都是手动设置的,但是没有运气