2013-02-23 32 views
0

我想在我的flex應用程序中顯示遠程swf,我能夠加載swf,但它在我的flex應用程序中沒有顯示(可見)。如何在flex UI組件中顯示遠程swf?

這裏是代碼

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> 

任何想法

感謝所有

+0

你檢查了你的遠程SWF嗎? contentloaderinfo尺寸說什麼? – user1875642 2013-02-24 11:24:38

+0

寬度和高度爲零。然而,獲取數據後,我的意思是一旦swf加載,寬度和高度手動設置,但沒有運氣 – niran 2013-02-24 14:09:02

回答

0

您的代碼段沒有界定 'L' 是

您遇到的最有可能的問題你現在的代碼是你將你的'l'添加到一個UIComponent中,該UIComponent沒有用於調整和定位它的子元素的內置代碼,因此你的'l'將沒有heig高和寬,有效地使其不可見。

我會使用SWFLoader加載另一個SWF文件並將其顯示爲應用程序的一部分。

+0

升是類型loader.I已經嘗試SWFLoader,但沒有運氣。我已編輯有問題的代碼 – niran 2013-02-23 15:24:54

+0

使用您的編輯代碼;你仍然沒有確定裝載機的大小;因此我猜它沒有高度或寬度。 – JeffryHouser 2013-02-23 23:27:42

+0

我試過你的建議,沒有運氣 – niran 2013-02-24 14:16:24