I am creating a game that uses tiling and xml files. I am trying to retrieve these files from an outside server. When I run the program in debug mode on my local machine, it works great. But when I upload to a server. I get this error
SecurityError: Error #2122: Security sandbox violation: LoaderInfo.content:
A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
Below is my code
private function init():void
{
game = new EngineApi();
gameObject.eApi = game;
gameObject.EG = this;
game.Tiling(true,800,640,80,80);
game.tileEg.offsY = 7000;
game.tileEg.ScrollLoop(true,0,1,true);//0,1
context.checkPolicyFile = true;
flash.system.Security.loadPolicyFile("http://mysite.com/images/tileSheet.png");
flash.system.Security.loadPolicyFile("http://mysite.com/images/world.xml");//map 0
flash.system.Security.loadPolicyFile("http://mysite.com/images/world1.xml");//map 1
flash.system.Security.loadPolicyFile("http://mysite.com/images/world7.xml");//world 7 and 8 are train track maps. map 2
flash.system.Security.loadPolicyFile("http://mysite.com/images/world8.xml");//map 3
flash.system.Security.loadPolicyFile("http://mysite.com/images/world9.xml");//Ending of 8 //map 4
flash.system.Security.loadPolicyFile("http://mysite.com/images/world10spaceInvader.xml");//Beginning of tracks being centered //map 5
flash.system.Security.loadPolicyFile("http://mysite.com/images/world11LoopBoss.xml");//Tracks loop (you fight boss) //map 6
flash.system.Security.loadPolicyFile("http://mysite.com/images/world12toDesert.xml");//map 7
flash.system.Security.loadPolicyFile("http://mysite.com/images/world2.xml");//map 8
flash.system.Security.loadPolicyFile("http://mysite.com/images/world3.xml");//map 9
flash.system.Security.loadPolicyFile("http://mysite.com/images/world13DesertDoubleTrain.xml");//map 10
flash.system.Security.loadPolicyFile("http://mysite.com/images/world14DoubleTrain.xml");//map 11
game.AddTileSheet("http://mysite.com/images/tileSheet.png");
game.tw = 80;
game.th = 80;
game.LoadTileSheets();
game.addEventListener("tileLoadComplete", prePareTiles);
//anything labeled with map (i.e. map 1) is the order of how the game see's it
game.addXml("http://mysite.com/images/world.xml");//map 0
game.addXml("http://mysite.com/images/world1.xml");//map 1
game.addXml("http://mysite.com/images/world7.xml");//world 7 and 8 are train track maps. map 2
game.addXml("http://mysite.com/images/world8.xml");//map 3
game.addXml("http://mysite.com/images/world9.xml");//Ending of 8 //map 4
game.addXml("http://mysite.com/images/world10spaceInvader.xml");//Beginning of tracks being centered //map 5
game.addXml("http://mysite.com/images/world11LoopBoss.xml");//Tracks loop (you fight boss) //map 6
game.addXml("http://mysite.com/images/world12toDesert.xml");//map 7
game.addXml("http://mysite.com/images/world2.xml");//map 8
game.addXml("http://mysite.com/images/world3.xml");//map 9
game.addXml("http://mysite.com/images/world13DesertDoubleTrain.xml");//map 10
game.addXml("http://mysite.com/images/world14DoubleTrain.xml");//map 11
game.loadXmlMaps();
clouds = new CloudManager(5);
clouds.minSpeed = 25;
clouds.maxSpeed = 35;
game.addGameChild(clouds);
}
Below is in my EngineApi() class
public function addXml(path:String):void
{
xmlDatas.push(path);
}
public function loadXmlMaps():void
{
var gLoader = new gameLoader();
gLoader.xmlToArray(xmlDatas.shift(),10,100);
gLoader.addEventListener("xmlComplete", FinishXmlMaps);
}
public function FinishXmlMaps(e:Event)
{
if(useTiles)
{
tileEg.mapHolder.push(gameLoader(e.currentTarget).tileArray);
}
if(xmlDatas.length > 0)
{
loadXmlMaps();
}else
{
dispatchEvent(new Event("XMLSCOMPLETE"));
}
}
And this is the code in my gameLoader class
public function xmlToArray(s:String, cols:Number, rows:Number):void
{
this.cols = cols;
this.rows = rows;
//load in tile sheet image
var xmlLoader;
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
xmlLoader.load(new URLRequest(s));
}
private function xmlLoadComplete(e:Event):void
{
var mazeData = new XML(e.currentTarget.data) as XML;
//loop through xml and add rows and columns to aTileMap array
for (var rowCtr=0;rowCtr<rows;rowCtr++) {
var tempArray:Array=new Array();
for (var colCtr=0;colCtr<cols;colCtr++) {
tempArray.push(mazeData.tilerow[rowCtr].tilecol[colCtr]);
}
tileArray.push(tempArray);
}
trace("xml done");
dispatchEvent(new Event("xmlComplete"));
}//END XMLLOAD
The code below is pretty much the process the data goes through to retrieve and translate the xml to an array. It all works. I just get an error because I guess its a crossdomain issue. My question is how do I resolve it.