FlickrGallery - Papervision3D

Posted by anup.narkhede on November 27, 2007

FlickrGallery 0.1 is ready to go :) It pulls out the latest 12 images from your Flickr album. You just need to pass nsid of the flickr account.

To get Flickr nsid, see the rss feed url of your photos. For example:
http://api.flickr.com/services/feeds/photos_public.gne?id=75426038@N00&lang=en-us&format=rss_200

Here 75426038@N00 is the nsid for my flickr account. Embed the flash file http://anup.info/FlickrGallery.swf?userid=your-nsid like any other swf control in your webpage.

SecuritySandbox Errors and PaperVision3D

Posted by anup.narkhede on November 27, 2007

I have been banging my head since past one week to resolve the Security Sandbox error issue with ActionScript 3.0 and Papervision 3D. This security thingy was needed badly to get my FlickrGallery working.

Error Description:

     SecurityError: Error #2122: Security sandbox violation: LoaderInfo.content:
     file:///C:/Documents and Settings/anup/My Documents/app/Final/bin/Final.swf
     cannot access http://farm3.static.flickr.com/2263/2043746131_8e36900f5d_t.jpg.
     A policy file is required, but the checkPolicyFile flag was not set when this media
     was loaded.
	at flash.display::LoaderInfo/get content()
	at Final/::imageLoaded()

Anyhow the flash application was not getting the LoaderContext’s checkPolicyFile flag and domain’s crossdomain.xml file. I searched for solutions all over the web including pv3d mailing list and then arrived at a solution for this problem.

My ActionScript 3.0 loader code looks like this:

     imageURL = string;
     var loaderContext:LoaderContext = new LoaderContext(true);
     var imageLoader:Loader = new Loader();
     imageLoader.load( new URLRequest(imageURL),loaderContext);
     imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, imageLoaded );

     private function imageLoaded(e:Event):void{
	var loadedBmp:Bitmap = e.target.content as Bitmap;
	var bmp:BitmapData = loadedBmp.bitmapData;
	var material:BitmapMaterial = new BitmapMaterial(bmp);
	material.doubleSided = true;
	images[imgCounter] = new Plane( material, 40, 40, 1, 1);
	rootNode.addChild(images[imgCounter]);
     }

I created a proxy script for my domain http://anup.info to route all flickr images through my domain. Found a cool php script at http://www.abdulqabiz.com/blog/archives/general/php_proxy_script_for.php

Then finally added one crossdomain.xml file at http://anup.info

     < ?xml version="1.0"?>
        < !DOCTYPE cross-domain-policy SYSTEM
          "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
        <cross -domain-policy>
            <allow -access-from domain="*" />
        </cross>>

Bravo! it works! Finally my FlickrGallery is ready to go live on external web sites.