Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 在Flex移动应用程序中加载外部图像_Actionscript 3_Apache Flex_Mobile_Loader_Crossdomain.xml - Fatal编程技术网

Actionscript 3 在Flex移动应用程序中加载外部图像

Actionscript 3 在Flex移动应用程序中加载外部图像,actionscript-3,apache-flex,mobile,loader,crossdomain.xml,Actionscript 3,Apache Flex,Mobile,Loader,Crossdomain.xml,我正在尝试将我的网站上的图像加载到我的Flex Mobile应用程序中。当我使用我的本地主机运行代码时,一切工作都很完美。但是,当我尝试从我的live网站加载图像时,我会出现以下错误: IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2036: Load Never Completed. URL: http://sortsports.com/images/players/nf

我正在尝试将我的网站上的图像加载到我的Flex Mobile应用程序中。当我使用我的本地主机运行代码时,一切工作都很完美。但是,当我尝试从我的live网站加载图像时,我会出现以下错误:

IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2036: Load Never Completed. URL: http://sortsports.com/images/players/nfl/sketch/8850x300.jpg" errorID=2036]
我使用加载程序加载图像,加载程序Context将checkPolicyFile设置为false

var lc:LoaderContext = new LoaderContext();
    lc.checkPolicyFile = false; // bypass security sandbox / policy file - does this effect quality when scaling? - See more at: http://www.onegiantmedia.com/as3--load-a-remote-image-from-any-url--domain-with-no-stupid-security-sandbox-errors#sthash.ZRnTf99k.dpuf
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, playerImageLoadCompleteHandler);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderIOErrorHandler);
    trace('loading: ' + remoteFileUrl);
    loader.load(new URLRequest(remoteFileUrl), lc);   // add a loader context to not check the policy file

    private function playerImageLoadCompleteHandler(event:Event):void
{
    var loaderInfo:LoaderInfo = event.target as LoaderInfo;
    playerImage.source = loaderInfo.content;

}

private function loaderIOErrorHandler(ev:Event):void{
    trace("Image not found and ioError: " + ev);
    playerImage.source = 'k';
 }
我在url的根目录中还有一个跨域策略:

    <?xml version="1.0"?>
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
我试着让你知道

//Security.allowDomain('http://sortsports.com/');
但我犯了个错误

SecurityError: Error #3207: Application-sandbox content cannot access this feature.
所以我把它放在了try catch中:

                try {Security.allowDomain("*");}catch (e) { trace("e.message: " + e.message); };

同样,该代码在localhost上运行良好。我认为不可能使用代理,因为这是一个移动应用。

尝试在不指定自定义LoaderContext和其他安全相关代码的情况下加载图像。在绝大多数情况下,您不需要提供这样的内容。您的加载程序是一个局部变量,它在能够完成其工作之前获取GC,然后加载永远不会完成。在本地系统上,由于图像加载的速度(加载在GC之前结束),该错误更难获得。作为快速修复,请尝试使用私有静态变量lc:LoaderContext=new LoaderContext()
                try {Security.allowDomain("*");}catch (e) { trace("e.message: " + e.message); };