How to get full URL when LoaderInfo.isURLInaccessible == true?
Why is Flash Security so hard to figure out?
I am trying to load an image; however, the image URL I 1st receive is actually a redirected URL. I wish to load the redirected URL, but I can't get the full redirected URL because LoaderInfo.isURLInaccessible is true even though I think I follow all the precautions detailed on the following page:
http://www.macromediademos.com/devnet/flashplayer/articles/fplayer10.1_air2_security_changes.html
Here is my sitaution...
I have an image URL: i.e. "http://www.foo.com/image.jpg"
I attempt to load the image ensuring that I set the LoaderContext's checkPolicyFile to "true"
var ur:URLRequest = new URLRequest( "http://www.foo.com/image.jpg");
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
var lc:LoaderContext = new LoaderContext();
lc.checkPolicyFile = true;
l.load(ur, lc);
When the Event.COMPLETE is dispatched, I discover that the loaded image's URL is not the one I first used ( "http://www.foo.com/image.jpg") instead the URL is a redirected URL "http://www.bar.com/image.jpg".
Because of sandbox issues, I can not use the loaded image and be able to manipulate the image. So instead I need to reload the image using the final URL. However, I cannot determine what the redirected URL is because the LoaderInfo.isURLInaccessible == true and LoaderInfo.url =="http://www.bar.com/", not "http://www.bar.com/image.jpg".
private function onLoad(e:Event):void {
var li:LoaderInfo = LoaderInfo(e.target);
trace("isURLInaccessible = " + li.isURLInaccessible); //output = "isURLInaccessible = true"
trace("li.url = " + li.url); //output = "li.url = http://www.bar.com/"
}
Acording to the Adobe Blog post (see URL above), I need to ensure two things: 1) LoaderContext.checkPolicyFile= true, and 2) the crossdomain policy file gives the proper permission.
I think I've met both o these criteria. The crossdomain file for BOTH http://www.foo.com/crossdomain.xml and http://www.bar.com/crossdomain.xml is the following:
<cross-domain-policy>
<allow-access-from domain="*"/>
<site-control permitted-cross-domain-policies="all"/>
</cross-domain-policy>
What am I doing wrong? How do I ensure that I can get the redirected URL and LoaderInfo.isURLInaccessible == false?
thanks!