2010-09-10 40 views
0

問題是:我有(例如)字體嵌入類,並且我想從應用程序存儲文件夾中加載外部SWF,但不是另一個本地路徑(「D:\ blah-blah \ 123.swf「)在空氣中,但你知道我不能在互聯網上找到(谷歌,Adode.com)從另一個沙箱中的內容加載外部類

Security.allowDomain() not working in AIR (documented on adobe.com) 


Trick with ApplicationDomain is not working (same documented on adobe.com) 

任何決定我要的,是獲得類參考從加載內容並在加載啓動器中使用。

有誰知道如何解決這個問題?

_

_

[主AIR-應用代碼片]

// function and one param (path to content) 
function tralala(_swfPath : String) 
{ 
    var l : Loader = new Loader(); 

     l.contentLoaderInfo. 
     addEventListener(Event.COMPLETE, 
          function(_e : Event) 
          { 
           var tmp = _e.target.content; 

           // call function from SWF and retrieving 
           // classes, but can't work with them 
           Font.registerFont(tmp._getRef()[0]); 


           // no error checking for clarity 
          } 
         ); 

     l.load(new URLRequest(_swfPath)); 
} 

_

_

:用於獲取初識

列表代碼

[外部SWF代碼]

function _getRef() : Array 
{ 
    // class1,2,3 are font classes imported in library 
    return [ class1, class2, class3]; 
} 

回答

1

我只是設法讓我的代碼工作。

因此,這裏的一切,我在的情況下別人做了同樣的問題:

  1. 使用一個FileStream

    stream.readBytes(字節)讀取SWF文件

  2. 創建一個新的Loader對象並使用LoaderContext加載該字節,var loader:Loader = new Loader(); loadercontentLoaderInfo.addEventListener(Event.COMPLETE,fontFileLoaded,false,0,true);

    var context:LoaderContext = new LoaderContext(); context.applicationDomain = ApplicationDomain.currentDomain; context.allowCodeImport = true;

    loader.loadBytes(bytes,context);

  3. 確保您不會在加載的swf中調用Security.allowDomain()。正如@Focker所說,它不適用於AIR。

  4. 無需加載使用Security.loadPolicyFile()策略文件

  5. 我曾經使用Flash CS3,通過添加新字體實例庫中創建的SWF文件。我沒有用[Embed]創建它們,因爲結果類被存儲爲TrebuchetMS_TrebuchetMS,而不是實際的類名TrebuchetMS。

  6. 我不必創建安全橋(LoaderInfo。childSandboxBridge)

我希望我不會忘記任何事情。

+0

Thx回覆。希望它能幫助別人。 – Focker 2011-07-28 20:51:29

相關問題