January 16th, 2011
- Flash
checkPolicyFile with redirects
Happy New Year everybody! Thought I would start it off right by sharing a little tidbit about working with cross domain files when there are redirects. Normally if you needs to access the bitmapdata from a file loaded on another domain you need to explicitly tell Flash to check the crossdomain.xml file. I'm not sure why this isn't the default.
loaderContext = new LoaderContext(true); loaderContext.checkPolicyFile = true; ... var yourLoader:Loader = new Loader(); yourLoader.load(YourURLRequest, loaderContext);
This works most of the time, unless the file you're loading is redirected, e.g., Facebook profile images. Flash isn't smart enough to check for the new domains crossdomain.xml file after a redirect, so you have to manually tell it. Like so:
Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
I typically put that right above the LoaderContext code. Problem solved and now you can use an open graph url to load a Facebook profile image.