Skip to main content
tropicanaclock
Known Participant
March 21, 2013
Answered

Getting Text value for an array, from an array

  • March 21, 2013
  • 2 replies
  • 466 views

I have two arrays, one creates x amount of boxes for the user to input text into, and the other "prints" the data into text boxes.

My issue: When I create the second array it creates the boxes, and I need to grab the text value off the first array.

Im having trouble with finding the correct directory and using it with the loop

printAryblk[PBArr].text = MovieClip(parent).blockoff.blockinpts.textArray100["one" + i].text;   // this is the broken code

I know my designations are off, and im not sure how to specify it correctly.

var printAryblk:Array = new Array();

for (var i:int =0; i<Printbloklin; ++i)

{

          trace(PBArr);

          printAryblk[PBArr] = new TextField();

          printAryblk[PBArr].name = PBArr;

          printAryblk[PBArr].y = 500;

          printAryblk[PBArr].x = 160 + (i * 15 + MovieClip(parent).blockoff.blockinpts.textArray100["one" + i].width );

          printAryblk[PBArr].width = 14;

          printAryblk[PBArr].type = TextFieldType.INPUT;

          printAryblk[PBArr].height = 30;

          printAryblk[PBArr].autoSize = TextFieldAutoSize.LEFT;

          printAryblk[PBArr].defaultTextFormat = PrintBlockF;

  printAryblk[PBArr].text = MovieClip(parent).blockoff.blockinpts.textArray100["one" + i].text;   // this is the broken code

          addChild(printAryblk[PBArr]);

}

var textArray100:Array = new Array();

for (var i:int =0; i<maxBlokLinne; ++i)

{

          trace(blockArr100);

          textArray100[blockArr100] = new TextField();

          textArray100[blockArr100].name = blockArr100;

          textArray100[blockArr100].y = 0;

          textArray100[blockArr100].x = 0;

          textArray100[blockArr100].width = 8.5;

          textArray100[blockArr100].type = TextFieldType.INPUT;

          textArray100[blockArr100].height = 30;

          textArray100[blockArr100].autoSize = TextFieldAutoSize.LEFT;

          textArray100[blockArr100].background = true;

          textArray100[blockArr100].backgroundColor = 0x86A798;

          textArray100[blockArr100].border = true;

          textArray100[blockArr100].defaultTextFormat = myFormat100;

          addChild(textArray100[blockArr100]);

}

This topic has been closed for replies.
Correct answer Ned Murphy

It's a bit hard to tell which are the arrays you are having a problem with... there appear to be maybe four of them in your code.

Regardless of that, the line you show in red appears to be trying to use text from something that doesn't exist yet and when it does exist it might not exxist where you are targeting it to be...   textArray100[whatever]  doesn't appear to be getting created until the next loop, so it can't ecist in the first one... and you are just using addCHild to plant it after it is created, whereas in the previous loop you are targeting it thru whatever MovieClip(parent).blockoff.blockinpts  might be

2 replies

kglad
Community Expert
Community Expert
March 22, 2013

you're showing 4 arrays (printAryblk,PBArr,textArray100,blockArr100) and no explanation of their relationship.

Ned Murphy
Ned MurphyCorrect answer
Legend
March 22, 2013

It's a bit hard to tell which are the arrays you are having a problem with... there appear to be maybe four of them in your code.

Regardless of that, the line you show in red appears to be trying to use text from something that doesn't exist yet and when it does exist it might not exxist where you are targeting it to be...   textArray100[whatever]  doesn't appear to be getting created until the next loop, so it can't ecist in the first one... and you are just using addCHild to plant it after it is created, whereas in the previous loop you are targeting it thru whatever MovieClip(parent).blockoff.blockinpts  might be