Jump to content
Search Community

ImageLoader and Facebook proxy

gibbz test
Moderator Tag

Recommended Posts

Hello,

I'm unable to use the great ImageLoader class to load an image generated through the Facebook proxy.

The image url is:

 

http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=185485354812569&v=1&size=z&cksum=35106c0ba3c5d297aa93474c3a44cfa1&src=http%3A%2F%2F89.31.74.164%2Fimages%2F100001536708917_1298290087609.jpg

 

The code used to load the image:

 

var queue:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:completeHandler, onError:errorHandler});
queue.append( new ImageLoader("http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=185485354812569&v=1&size=z&cksum=35106c0ba3c5d297aa93474c3a44cfa1&src=http%3A%2F%2F89.31.74.164%2Fimages%2F100001536708917_1298290087609.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:1, width:250, height:150, scaleMode:"proportionalInside"}) );
queue.load();

function completeHandler(event:LoaderEvent):void {
  trace("image loaded");
}

function errorHandler(event:LoaderEvent):void {
   trace("error occured with " + event.target + ": " + event.text);
}

 

Executing the above code the player throw the Error#2036: Load Never Completed.

Using the same image url with standard Loader class all works fine.

Thank You!

Link to comment
Share on other sites

Looks like another Flash bug/inconsistency. The issue has to do with the fact that in order to work around some other Flash bugs, the URL must be broken down into the main URL and the various GET stuff at the end (pairs like v=1&size=z, etc.) must be put into a URLVariables object. However, when Flash actually submits the URLRequest, it encodes the variable data to make it "safe" (technically you're not supposed to use special characters like periods, so they get encoded to %2E). Apparently the proxy you're submitting to doesn't decode the URL variables.

 

You can verify that it's not a LoaderMax-specific bug like this:

var loader:Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, test);
var request:URLRequest = new URLRequest("http://platform.ak.fbcdn.net/www/app_full_proxy.php");
var vars:URLVariables = new URLVariables();
vars.src = "http%3A%2F%2F89.31.74.164%2Fimages%2F100001536708917_1298290087609.jpg";
vars.cksum = "35106c0ba3c5d297aa93474c3a44cfa1";
vars.size = "z";
vars.v = "1";
vars.app = "185485354812569";
request.data = vars;
loader.load(request);

function test(event:Event):void {
trace("DONE");
}

 

That code should work fine, but it throws the error you mentioned. I don't see a way to tell the URLVariables or URLRequest to NOT encode the values so I'm not entirely sure how to accommodate your proxy other than to implement a server-side fix that correctly decodes values. Again, it's important to use the URLVariables because of several other bugs in Adobe's Loader/URLRequest classes so it's a bit of a catch-22. If anyone else knows of a workaround, let me know.

Link to comment
Share on other sites

Thank You as usual for the clarification! A case-specific workaround can be to decode the url before passing it to ImageLoader.

For this url it seems to work:

 

queue.append( new ImageLoader(decodeURIComponent("http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=185485354812569&v=1&size=z&cksum=35106c0ba3c5d297aa93474c3a44cfa1&src=http%3A%2F%2F89.31.74.164%2Fimages%2F100001536708917_1298290087609.jpg"), {name:"photo1", estimatedBytes:2400, container:this, alpha:1,  scaleMode:"proportionalInside"}) );

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...