Monday, February 8, 2010

Error #2122: Security sandbox violation: BitmapData.draw:

SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: http://myDomain
/my.swf cannot access http://profile.ak.fbcdn.net/v225/1105/89/t708240324_893.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
at flash.display::BitmapData/draw()
at com::someClass/someFunction()

I received this on a game I am developing for facebook. Problem was here :

var bmd:BitmapData = new BitmapData(w,h);
try {
bmd.draw(someSprite);
}
catch (err:SecurityError) {
//do something
}

someSprite contained a sprite anotherSprite which had an image which was
loaded from facebook. I didn't need anotherSprite , so I did this :

1.
var ind:int = someSprite.getChildIndex(anotherSprite);
someSprite.removeChild(anotherSprite);
try {
bmd.draw(someSprite);
}
someSprite.addChildAt(anotherSprite,ind);

2. Simply doing someSprite.visible = false didn't help.

3. A better way is to do this, while loading the picture :

Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
context.applicationDomain = ApplicationDomain.currentDomain;

try {
imageLoader.load(urlReq,context);
} catch (error:Error) {
trace("something");
}

Saturday, February 6, 2010

php eval function usage

evalTest.php :

$str = '$db_name';
echo $str;
require 'utils.php';
evalTest($str);

utils.php :

function evalTest($str) {
require 'db_settings.php';
eval("\$str = \"$str\";");
echo $str;
}

db_setting.php :
$db_name = "mydb";

session_start hangs in php

Problem : in my php.ini, session.save_path was incorrectly set.
Fix: either change the path in php.ini or better : use session_save_path function.

Blog Archive