Avoiding AS3 security sandbox
While working on SoundRiver in 2007, I just wanted to get the album cover somewhere from other domain of the web as GoogleImage, Amazon, ...When you publish it in flash IDE, it ok.
But on the web you will fight against the Flash Security Sandbox.So ?
You need to avoid the security sandbox to succeed. If no crossdomain.xml is located on this server you should try something else.How does it works ?
Easily, you just need a php script on your server. Rather than load a file located on other domain, just ask the script to load it for you...Here is a php script to load pictures from the web.
- <?php
- $infos=pathinfo($_GET['url']);
- $extension = strtolower($infos['extension']);
- switch($extension){
- case "jpg":
- header("Content-Type: image/jpeg");
- $img_in = imagecreatefromjpeg("http://".$_GET['url']);
- imagejpeg($img_in);
- break;
- case "png":
- header("Content-Type: image/png");
- $img_in = imagecreatefrompng("http://".$_GET['url']);
- imagepng($img_in);
- break;
- case "gif":
- header("Content-Type: image/gif");
- $img_in = imagecreatefromgif("http://".$_GET['url']);
- imagegif($img_in);
- break;
- }
- ?>
In this example there only two differents php script. One ask googleimage with our request, then send the result using adequat regex. Then the second will load the pictures
2 comments about this entry