2 Replies Latest reply on Oct 15, 2010 1:30 AM by dn0myar06

    function for assigning characters to textfield

    dn0myar06

      i'm having a problem with my function in assigning characters to a set of textfields...

      i made a set of textfields for my crossword puzzle with an instance name of c111 for the 1st textfield c112 for 2nd, c113 3rd etc...

       

      here's my code...

      var tl:MovieClip=this
      var alphaS:String="abcdefghijklmnopqrstuvwxyz";
      var alphaA:Array = alphaS.split("");

      var kLO:Object = new Object();
      kLO.onKeyDown = function() {
        for(var j:Number=0;j<26;j++){
           if (Key.isDown(65+j || 97+j)) {
            _root.ctr++;
            if (_root.ctr < 9) {  //1st set 8 text fields
               tl["c"+(110+_root.ctr)].text = alphaA[j];
             }
           }
        }
      }
      Key.addListener(kLO);

      this actually work on first set of dynamic textfield...but when i used it on my 2nd set...with instance names of c121, c122, c123, c124 etc...

      it also changes my first set of textfields...and it only assign to instance names with even num (c122, c124)

       

      here's the other code for my other mc

       

      var tl:MovieClip=this
      var alphaS:String="abcdefghijklmnopqrstuvwxyz";
      var alphaA:Array = alphaS.split("");

      var kLO:Object = new Object();
      kLO.onKeyDown = function() {
      for(var j:Number=0;j<26;j++){
         if (Key.isDown(65+j || 97+j)) {
            _root.ctr++;
            if (_root.ctr < 5) { //2nd set has 4 textfields
              if (_root.ctr == 2) { 
                c116.text = alphaA[j];
               }
               tl["c"+(120+_root.ctr)].text = alphaA[j];
             }
           }
      }
      }
      Key.addListener(kLO);

      i tried to rename this one kLO2, but same outcome...hop you guys could help me with this one...