Using Amazon S3 With Loaded Flash Images

Posted by Tres Fri, 15 Aug 2008 18:00:00 GMT

Security policies in flash require that images be loaded from the same domain as the swf file is hosted on. This doesn’t really become an issue until you’re using BitmapData.draw() to convert the flash vector image into a raster graphic.

If you’re seeing SecurityError: Error #2122 when attempting to use BitmapData.draw(), you can fix this by setting up a Policy file on S3 for your bucket.

Now you might be saying, “I don’t have access to anything outside my bucket, how can I set up a file named crossdomain.xml in the root level of s3.amazonaws.com?” Well, never fear, Amazon has already given us a way to access buckets via vhost name. Just use bucket_name.s3.amazonaws.com to access your files, and you’re golden.

Update 15 Aug 2008

My friend, Lyle just wrote to say that you can also use a CNAME with s3 to have the same effect:

BTW, if you set up a CNAME to point to s3.amazonaws.com and create a bucket with the same name, you can access it that way as well. i.e. http://s3.vmann.net/public_key.asc is my gpg public key, stored in bucket named ‘s3.vmann.net’

Posted in ,  | Tags , , , ,