0

I am trying to load images from my website on my Flex Mobile Application. When I run the code using my localhost, everything works perfectly. However, when I try to load the images from my live website, I get the error:

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]

I am using a Loader to load the image and a LoaderContext setting checkPolicyFile to 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';
 }

I also have a crossdomain policy in the root of the url:

    <?xml version="1.0"?>
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

I load the crossdomain like this:

Security.loadPolicyFile(Globals.currentDomain + "/crossdomain.xml");

And I try to allowDomain

//Security.allowDomain('http://sortsports.com/');

But I get an error

SecurityError: Error #3207: Application-sandbox content cannot access this feature.

So I put it in the try catch:

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

Again, the code works great on localhost. I don't think using a proxy is a possibility as this is a mobile app.

Bryan
  • 17,201
  • 24
  • 97
  • 123
  • 1
    Try to load your image without specifying custom LoaderContext and without other Security related code. You do not need to provide such things in vast majority of cases. – Ingweland Sep 10 '14 at 07:07
  • Your loader is a local variable that gets GC before being able to finish its job and then load never completes. On local system that error is more difficult to get due to the speed at which image load (the loading ends before GC). – BotMaster Sep 10 '14 at 19:55
  • As a quick fix try `private static var lc:LoaderContext = new LoaderContext();` – Alexander Farber Sep 13 '14 at 09:16

0 Answers0