Since recently we create a thumbnail image of every Floorplanner plan that is saved. To create a 240×180px image we use the BitmapData class (AS2) to get the pixel info and we send it to our server to create the PNG/JPG.
It can happen that the content (images, swf’s) has to be loaded from a different server then the server that holds the HTML page with the Flash app. We noticed that the Flash Security Sandbox doesn’t like that (surprise!) by not allowing us to use the BitmapData.draw(..) method.
Abdul found a solution for AS3 and we ported it to AS2. We only needed a way to load the crossdomain.xml file from the domain of the HTML page. This sniplet uses Javascript to determine the domain and loads the policy file (crossdomain.xml) from it.
1 2 3 4 5 | var url:String = String( ExternalInterface.call( "function(){ return document.location.href.toString();}" )); var split:Array = lCurrentUrl.split( "/" ); System.security.loadPolicyFile( "http://"+ split[2] +"/crossdomain.xml" ); |
Tags: actionscript2, cross domain



August 12th, 2008 at 2:17 pm
I am now trying to find the url of the site in which my swf is embedded, am using the above said externalinterface function in my swf, but all i am getting is a null string … what mistake am i doing, do i have to make any other changes when i publish.. i am now publishin with settings as allow access to all network..
am using flash cs3.. pls help.
August 16th, 2008 at 10:10 am
Hi Dinesh,
The code snippet above is ActionScript 2 and since you are using Flash CS3 you’re working with ActionScript 3. We will be porting the Floorplanner 2D app from AS2 to AS3 the coming month. At this moment I’m not yet very familiar with AS3, so I’m sorry to tell you that I can’t help you.
September 12th, 2008 at 11:08 am
[...] (and trouble) of BitmapData in combination with loading content from other domains. I thought we solved it a while ago, but it in some situations it didn’t work… I definitely hope this is my [...]