URLLoader fails randomly
Hi everyone,
I'm here because it's been 3 days since I've this problem, and I can't find any solution...
Here is the thing: I use a URLLoader to load a PHP script, and receive an answer. Ok, fine, but the problem is: sometimes it does'nt work...
Yeah, my big problem is the SOMETIMES. I can't figure out why would it only be sometimes, it's killing me. Anyway, it doesn't generate any error, it just stop in the middle of the script.
Here is some code (in french mostly, sorry):
var enveloppe:URLLoader = new URLLoader;
function envoyerCode(event){
//Sending PHP Script to database
var variablesLocales:URLVariables = new URLVariables();
var scriptPromo:URLRequest = new URLRequest("http://www.amiciebijoux.com/socialbuy/promo.php");
variablesLocales.codeEntree = promoinput.text;
scriptPromo.data = variablesLocales;
//Listeners
enveloppe.addEventListener(IOErrorEvent.IO_ERROR, indiquerErreur);
enveloppe.addEventListener(ProgressEvent.PROGRESS, afficheProgres);
enveloppe.addEventListener(Event.OPEN, afficheOpen);
enveloppe.addEventListener(Event.COMPLETE, donneesChargees);
//Loading
enveloppe.load(scriptPromo);
}
/*
var myRequest1:URLRequest;
myRequest1 = new URLRequest("http://amiciebijoux.com/prestashop/cart.php?add&id_product="+id_products+"&token=199504cd3ef2639be7c05c8cc45d5e4d");
sendToURL(myRequest1);
*/
function afficheOpen(e:Event){
txtinfo.text = "Fichier ouvert";
trace("Fichier ouvert");
}
function afficheProgres(e:ProgressEvent){
txtinfo.text = "Bytes loaded: "+e.bytesLoaded+"/"+e.bytesTotal;
trace("Bytes loaded: "+e.bytesLoaded+"/"+e.bytesTotal);
}
function indiquerErreur(erreur:Event):void
{
trace('Erreur lors du chargement : ' + erreur);
txtinfo.text = ""+erreur;
}
var resultat;
function donneesChargees(e:Event):void
{
resultat = (e.target as URLLoader).data;
//tf.text = (e.target as URLLoader).data;
if(resultat.indexOf("Code bon")>=0){
//if good code
}
else if(resultat.indexOf("Code mauvais")>=0){
//if wrong code
}
else{
//else
}
}
You can try this at http://www.amiciebijoux.com/socialbuy
Thank you for your help and your time! ![]()