A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Creating unique textFields in a For loop.

Threaded View

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    12

    Creating unique textFields in a For loop.

    I have a for loop that runs depending on the length of an XML file. What I want to do is create a unique text field for each run through of the loop, and give it it's own position on the stage, and finally assign it the text from an external text file that is specified in the XML file. Everything I know how to do except creating the textfields.

    for(var i:int = 0; i < blogXMLList.length(); i++)
    {
    var txtHolder:TextField = new TextField();
    txtHolder.x = textX;
    txtHolder.y = textY;
    txtHolder.width = textX;
    txtHolder.height = textY;
    txtHolder.multiline = true;
    txtHolder.wordWrap = true;
    textX += 50;
    textY += 50;
    addChild(txtHolder);

    blogPostRequest = new URLRequest(blogXMLList[i].attribute("file"));
    blogPostLoader.load(blogPostRequest);
    blogPostLoader.addEventListener(Event.COMPLETE, loadTXT);

    function loadTXT(event:Event):void
    {
    txtHolder.text = event.target.data;
    }
    }
    This code creates only one Text Field, but then replaces it's text with new text with each run through. Please help, this has been annoying me for quite a while.
    Last edited by AffinityFX; 10-28-2008 at 10:02 AM.

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