5 Replies Latest reply on Mar 19, 2007 7:31 AM by kglad

    There's got to be a better way.

    logeye Level 1
      Greetings all,

      I've beat my head against the wall till it hurts. Looking for text help. Flash 8

      I have a form. I dynamically create the text fields. I name them a number so I can set the Focus. Each textField is restricted to numbers and 1 maxChars. I can place the cursor in any textField and type in a number and it seems to work. When I reposition the cursor to the left of a number I have already inputted that textField gets messed up. If I put in a String Opps. There's got to be a better way.

      Any ideas? Here's the code. Thanks for looking at this.

      =================================================================================
      var z:Number = 1;
      var tfld:Number = 0;
      Monitoring = function () {
      var TabOrderStart:Number = 0;
      var maxRows:Number = 4;
      var xStart:Number = 263;
      var yStart:Number = 400;
      var xOffset:Number = 17.35;
      var yOffset:Number = 19.5;
      var txtFieldWidth:Number = 15;
      var txtFieldHeight:Number = 18;
      var maxColumns:Number = 31;
      for (var j:Number = 0; j<maxRows; j++)
      {
      for (var i:Number = 0; i<maxColumns; i++)
      {
      tfld++;
      this.createTextField(tfld, this.getNextHighestDepth(), xStart+(xOffset*i), (yStart+(yOffset*j)), txtFieldWidth, txtFieldHeight);
      with (this[tfld])
      {
      TabOrderStart++;
      tabIndex = TabOrderStart;
      type = "input";
      maxChars = 1;
      restrict = "0-9";
      if (i == 3)
      {
      width = 20;
      maxChars = 1;
      }
      border=true;
      background = true;
      //this[tfld].setNewTextFormat(tfmt3);
      //this[tfld].size = 10;
      text = "X";
      }
      }
      }
      };
      Monitoring();
      var myKeyListener:Object = new Object();
      myKeyListener.onKeyUp = function() {
      var hereIam:String = Selection.getFocus();
      target = hereIam.substr(8, target.maxChars);
      //if (Key: getKeyPressed() = a number){
      tab = Number(target)+1;
      if (tab>tfld)
      {
      tab = 1;
      }
      //}
      Selection.setFocus(tab);
      };
      var myMouseListener:Object = new Object();
      myMouseListener.onMouseUp = function() {
      var hereIam:String = Selection.getFocus();
      target = hereIam.substr(8, target.maxChars);
      tab = Number(target);
      Selection.setFocus(tab);
      };
      Key.addListener(myKeyListener);
      Mouse.addListener(myMouseListener);

      ====================================================================

      Thanks again.