Skip to main content
Participant
October 23, 2024
Answered

String Characters are removed from String array

  • October 23, 2024
  • 1 reply
  • 372 views

Hello,
I have defined a String array and would like to iterate through the entries: 

var evArr: Array = new Array("empty", "ev1", "ev2", "ev3", "ev4", "ev5", "ev6", "ev7", "ev8", "ev9", "ev10", "ev11", "ev12", "ev13", "ev14", "ev15", "ev16", "ev17"); 

var countEvs:Number = 17;

var concatArray: String;
var i:Number;	
for (i = 1; i <= countEvs; i++) {
	concatArray= concatArray+ evArr[i];
}
textField.text = concatArray;


As a result I get:
"nulle1e2e3ee5e6e7eee1e11e12e13e1e15e16e17"

Does anyone know why are the "v"s removed? Why is there a problem with the numbers 4, 8, 9, 10, 14?

Thank you a lot in advace!

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

You should initialize concatArray as "". Other than that, if you're not seeing those characters, the font family you're using is probably not embedded.

 

But if all you want to do is to display the items from the array, starting from the index 1, in a text field, I think it's eaiser to use some methods from the Array class. For example:

 

textField.text = evArr.slice(1).join("");

 


Regards,

JC

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
October 23, 2024

Hi.

 

You should initialize concatArray as "". Other than that, if you're not seeing those characters, the font family you're using is probably not embedded.

 

But if all you want to do is to display the items from the array, starting from the index 1, in a text field, I think it's eaiser to use some methods from the Array class. For example:

 

textField.text = evArr.slice(1).join("");

 


Regards,

JC

Participant
October 23, 2024

Hi,
Thanks for the tip regarding the font, it was indeed the reason. A different font worked!
Best regards

JoãoCésar17023019
Community Expert
Community Expert
October 23, 2024

Nice! You're welcome.