Skip to main content
Participant
July 11, 2011
Question

URLLoader fails randomly

  • July 11, 2011
  • 1 reply
  • 382 views

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!

This topic has been closed for replies.

1 reply

renatobox
Participant
July 11, 2011

Have you tried local? To see if it is the server?

CrumbleFrAuthor
Participant
July 11, 2011

hard to say :/

sadly, on my computer it has always worked, even the online version. So the local version too.

But on many other computers it doesn't always work...

I wanted to add that the problem is about the redeem coupon, in the link I gave.

When it doesnt work, it freezes.