23 Replies Latest reply on Feb 1, 2011 12:53 PM by kglad

    How do I write this as a loop?

    Ron Colmen Level 2

      How do I write this code to function as follows.

      When btn1 is clicked, SenderLoad should be "clay" AND when btn2 is clicked, SenderLoad should be "iron", etc...

       

      var mgB:Array = [btn1, btn2, btn3, btn4];

      var mgBW:Array = ["clay", "iron", "cotton", "leather"];

       

      var SenderLoad:LoadVars = new LoadVars();

      var ReceLoad:LoadVars = new LoadVars();

       

       

      var mgNum:Number=0;

      for (i=0; i<mgBW.length ; i++){

      mgBW[i].onRelease = function () {

      mgNum++

       

      SenderLoad.word = mgB[mgNum];

      SenderLoad.sendAndLoad("http://www.web.com/my.php",ReceLoad,"POST");

      ReceLoad.onData = function(src) {

      var messageA:Array = src.split(",,,");

      ldrB2.html=true;

      for(var i:Number=0; i<messageA.length; i++){

                 var a:Array=messageA[i].split(",,");

         ldrB1.htmlText +=a[0];

         ldrB2.htmlText +=a[1];

      }

      }

      }

      };