A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Dynamically Generate Dynnamic Text Boxes

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Posts
    184

    Dynamically Generate Dynnamic Text Boxes

    is there a way to creat dynamic text boxes as variables in a for loop?
    this doesn't work but might give you and idea of what I am talkinga bout
    for (var z = 0; z < _root.NUM_ROWS ; z++)
    {
    create dyntxtbox var item[z];
    create dyntextbox var item[z]p;
    create dyntextbox var item[z]d;
    }


    then it keep creating those three for the number that is passed in the _root.NUM_ROWS variable ... hope that makes sesnes.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Here's some code which creates a grid of dynamic text boxes, in the manner you describe.

    code:

    NUM_ROWS = 4;

    var layer = 1;
    var txt;
    for (var z = 0; z < NUM_ROWS; ++z)
    {
    _root.createTextField('tfa_'+z, layer, 10, z*30, 100, 30);
    txt = _root['tfa_'+z];
    txt.text = "Row: " + z + ": " + "A";
    layer++;

    _root.createTextField('tfb_'+z, layer, 150, z*30, 100, 30);
    txt = _root['tfb_'+z];
    txt.text = "Row: " + z + ": " + "B";
    layer++;

    _root.createTextField('tfc_'+z, layer, 300, z*30, 100, 30);
    txt = _root['tfc_'+z];
    txt.text = "Row: " + z + ": " + "C";
    layer++;
    }


  3. #3
    Senior Member
    Join Date
    Jul 2002
    Posts
    184
    wow thats great, I even understand it ... is there away to set the value of the "variable" for the text box rather than the instance name in this fashion?

  4. #4
    Senior Member
    Join Date
    Jul 2002
    Posts
    184
    never mind i got it ...


    txt.variable = txt;

    I'm not as dumb as i thought I might be. ehhe.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center