Skip navigation
Currently Being Moderated

creating a dynamic text box inside a movieclip using a for loop

Aug 7, 2012 2:39 PM

I am having issues creating several dynamic text boxes inside a movieclip using a for loop.  I am using AS 2.  Here is the code I have created thus far

 

var leading:Number = 0;

function drawClip():Void

{

    this.createEmptyMovieClip("mc", 10);

    for(i=0;i<5;i++)

    {

        mc.createTextField("textBoxes" + i, this.getNextHighestDepth(), 0, leading, 200, 200)

        mc["textBoxes" + i].text = i;

        leading += 20;

    }

}

drawClip();

 

It does create a mc but only display the number 5

 

Any thoughts?

 
Replies
  • Currently Being Moderated
    Aug 7, 2012 3:32 PM   in reply to jencarter

    You are cionstantly overwriting the previously created textfield due to using the wrong depth definer.  You are pointing to "this" to get a depth value, but planting it inside "mc", so it is always going to the same depth since "this" 's depth index doesn't change.  Use...

     

    mc.createTextField("textBoxes" + i, mc.getNextHighestDepth(), 0, leading, 200, 200)

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 8, 2012 4:52 AM   in reply to jencarter

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points