URLLoader Event.Complete не стреляет
Я пытаюсь загрузить данные из простого файла PHP. Я получаю сообщение IOErrorEvent, в котором говорится: "Невозможно сделать запрос (может быть заблокирован из-за междоменных ограничений)". Это работает в AS3, но я пытаюсь заставить его работать в Haxe + OpenFL (нацеленный на HTML5). Код успешно отправляет счет, но не завершает загрузку (выбрасывая IOErrorEvent).
import openfl.net.URLVariables;
import openfl.net.URLRequest;
import openfl.net.URLLoader;
import openfl.events.IOErrorEvent;
import openfl.events.SecurityErrorEvent;
import openfl.system.Security;
public function save() {
Security.allowDomain("www.roomrecess.com");
Security.allowDomain("roomrecess.com");
var sender:URLLoader = new URLLoader();
var myVar:URLVariables = new URLVariables();
myVar.score = score;
var website:URLRequest = new URLRequest("http://www.roomrecess.com/php/boomSave.php");
website.data = myVar;
sender.addEventListener(Event.COMPLETE, loadComplete);
sender.addEventListener(IOErrorEvent.IO_ERROR, IOEErrorHandler);
sender.addEventListener(SecurityErrorEvent.SECURITY_ERROR, SecEvHandler);
sender.load(website);
}
public function IOEErrorHandler (e:IOErrorEvent)
{
ground[0].visible = false;
scoreDisplay.text = e.text;
scoreFormat.size = 10;
scoreDisplay.setTextFormat(scoreFormat);
}
public function SecEvHandler (e:SecurityErrorEvent)
{
ground[4].visible = false;
}
public function loadComplete(e:Event) {
Security.allowDomain("www.roomrecess.com");
Security.allowDomain("roomrecess.com");
background.visible = false;
sender.removeEventListener(Event.COMPLETE, loadComplete); //changed from loader to sender to match save()
outputTxt.text = e.target.data;
bytes = outputTxt.text;
mystring = bytes.toString();
stats = mystring.split(" "); //changed from int array to string array
standings();
loadCompleteVar = true;
}