Why my flash is not getting the JSON data from a s

2019-09-09 21:43发布

I am creating a flash project where I load data from server. When I run that from flash software using Ctrl+Enter or create exe then that works but when I run swf normally or using a browser then it is not working.

I tried to add this code but not working

Security.loadPolicyFile("policy.xml");
or
Security.allowDomain("192.168.10.8");
Security.allowDomain("www.example.com");

My policy.xml is

<cross-domain-policy> 
    <allow-access-from domain="*" /> 
    <allow-access-from domain="www.example.com" /> 
    <allow-access-from domain="192.168.10.8" /> 
</cross-domain-policy>

Please advice me.

3条回答
走好不送
2楼-- · 2019-09-09 22:03
混吃等死
3楼-- · 2019-09-09 22:12

I had a similar problem. Flash will initially try to get the flash policy from a different port (843). See this: http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

查看更多
Fickle 薄情
4楼-- · 2019-09-09 22:21

I suggest to try LoaderContext class. Here is example code:

Security.allowDomain("*");
Security.allowInsecureDomain("*");

var loader:URLLoader = new URLLoader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onDataLoaded);
loader.load(new URLRequest("http://www.example.com/json_file_path.json"), new LoaderContext(true));
查看更多
登录 后发表回答