Je crée un jeu qui utilise des fichiers de mosaïque et de xml. J'essaye de récupérer ces dossiers d'un serveur extérieur. Lorsque j'exécute le programme en mode débogage sur ma machine locale, cela fonctionne très bien. Mais quand je télécharge sur un serveur. Je reçois cette erreurSecurityError: Erreur n ° 2122: Violation du sandbox de sécurité: LoaderInfo.content:
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.
Voici mon 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);
}
Ci-dessous dans mon EngineApi() classe
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"));
}
}
Et voici le code dans ma classe gameLoader
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
Le code ci-dessous est à peu près le processus que les données passent pour récupérer et traduire le fichier XML en un tableau. Tout fonctionne. J'ai juste une erreur parce que je suppose que c'est un problème de crossdomain. Ma question est comment puis-je le résoudre.
Tout ce fichier de politique est encore assez confus pour moi, mais après avoir lu les liens que vous avez donnés je peux maintenant voir pourquoi votre réponse semble encore plus confuse ... Donc, je me sens obligé d'ajouter une autre réponse ici ou fortement éditez le vôtre. Que dis-tu? – cregox
Veuillez ajouter une autre réponse. –