dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: dynamic text fields

  1. #1
    absent
    Join Date
    Aug 2000
    Location
    NB, Canada
    Posts
    155

    dynamic text fields

    Hello there!

    wow it's been a while since i've been here, so i'd like to start things off with a question! ^_^

    i'm working on this code for dynamic text fields... i got it working just fine, however i'm trying to make a loop and then build a new text field for the number of entities but i just can't get it to work...

    Code:
    _global.num_entities_ = 5;
    if (_global.num_entities_ != 0) {
    	for (i=0; i<_global.num_entities_; i++) {
    		_Ypos = i*16;
                    _i = "_" + i;
    		_root.createTextField(_i, i, 0, _Ypos, 150, 16);
    		_i.border = true;
    		_i.borderColor = "0xFF0000";
    		_i.text = "Watson, i need you!";
    		trace(_i);
    		trace(_Ypos);}
    } else {
    	trace("There are no Entity values.");
    }
    stop();
    the problem seems to be with the "_i" as a name for the text field.. it just dosn't want to work...

    anyone have any clues how to get around this or fix my poor code. ^_^

    thanks a lot!
    - g

  2. #2
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476
    I think this line should be:
    Code:
    _root.createTextField("_i", i, 0, _Ypos, 150, 16);

  3. #3
    absent
    Join Date
    Aug 2000
    Location
    NB, Canada
    Posts
    155
    indeed the code is supposed to be with the "_i" how ever that gives the text field the name _i and not _0, _1, _2, etc. etc.
    i'm quite puzzeled by this one.. ^_^;;;


    i have already tried:

    Code:
    _root.createTextField("_" + i, i, 0, _Ypos, 150, 16);
    with no luck, so i moved on to what is currently in my code:

    Code:
    _i = "_"+i;
    _root.createTextField(_i, i, 0, _Ypos, 150, 16);
    in this one i was hoping the name of the field could be a variable and would change according to the loop number... much like how i have the _Ypos.

    Thanks!
    - g

  4. #4
    absent
    Join Date
    Aug 2000
    Location
    NB, Canada
    Posts
    155

    bump

    sorry... anyone?.. ^_^
    - g

  5. #5
    Senior Member
    Join Date
    Oct 2001
    Posts
    135
    did you try to give a alphabetic starting for var e.g. something like

    ("Inst_" + i)

    also remember to put ( & ) around the instance name param in createTextField

    -Mav

  6. #6
    absent
    Join Date
    Aug 2000
    Location
    NB, Canada
    Posts
    155

    i'm on crack!

    Thanks for your reply Maven5, i got it just a few moments ago... i'll post my code for anyone that wants to know how i did it, there's 'prolly a better way..

    Code:
    if (8 != 0) {
    	for (i=0; i<8; i++) {
    		_Ypos = i*16;
    		_root.createTextField("_"+i, i, 0, _Ypos, 150, 16);
    		eval("_"+i).border = true;
    		eval("_"+i).borderColor = "0xFF0000";
    		eval("_"+i).text = "text field "+i;
    		//trace(i);
    	}
    } else {
    	trace("There are no Entity values.");
    }
    stop();
    Thanks Again!
    - g

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