A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: For Loop and Text Boxes

  1. #1
    Junior Member
    Join Date
    Jul 2005
    Posts
    17

    For Loop and Text Boxes

    I'm trying to use a for loop to populate text boxes with results from an array and I have the text boxes named sequencially (txtArtist1, txtArtist2). I have tried the following and variations on it, but nothing seems to work. Is it even possible to do something like this:

    for (x=1;x<13;x++){
    art = "txtArtist" + x + ".text"
    art.text = Results[0][x]
    }

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    the player needs to know where to look - you need to supply it an object reference - in this case, the parents of the textfields. that and bracket notation should do it, like so
    Code:
    //assuming textfields are in _root
    for (x=1;x<13;x++)_level0["txtArtist" + x].text=Results[0][x];
    note the ommission of the dot on the left, and the inclusion of it on the right. that's requisite.

    hth, gl

  3. #3
    Junior Member
    Join Date
    Jul 2005
    Posts
    17
    Awesome. Thanks you so much. That saves about 200 lines in my code.

    Highly appreciated.

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174

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