Flash AS3 Getting Security sandbox violation when trying fetch an external swf

后端 未结 3 1495
再見小時候
再見小時候 2021-01-18 14:32

Hii, I\'m tring to load swf file to my flash application from a different server. When i try to load it on flash IDE (crl+enter) everything is working fine, but when i run t

相关标签:
3条回答
  • 2021-01-18 15:11

    Solution: for Flex 4.x (Currently 4.6) and AS3 in Flash Builder:

        import flash.system.SecurityDomain;
        import flash.system.ApplicationDomain;
        import flash.system.LoaderContext;
        var loaderContext:LoaderContext = new LoaderContext();
        loaderContext.applicationDomain = ApplicationDomain.currentDomain;
        loaderContext.securityDomain = SecurityDomain.currentDomain; // Sets the security 
    

    context to resolve Error # 2121

    ... now load your SWF with

    loader.load(new URLRequest(webServerWebURL),loaderContext);
    
    0 讨论(0)
  • 2021-01-18 15:19

    Add your working folder in the Global Security Settings panel. This allows you to load external files from a single SWF in your file system. Its the same if you want a.swf to load b.swf even if they is located in the same folder.

    • Go to the Settings panel: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
    • Choose "Add Location" from the dropdown
    • Click "Browse for folder" and add the folder containing your SWF

    This will allow your SWF to read external files.

    This should not be a problem if you upload you SWF to a server though.

    0 讨论(0)
  • 2021-01-18 15:32

    Your error is from the external location not having a cross domain file, not you. Check out this tutorial on using a bridge file to communicate with an external api. I used as3 and php in this example. The trick is to maintain control of the cross domain file on your domain.Then let your server communicate with the api.

    0 讨论(0)
提交回复
热议问题