How can I prevent AS3 from automatically adding a line break?


I have an issue with a specific string variable. It is automatically adding a line break after the text in the string characterName. On this frame I have a input text box with an instance name of name_Input and a submit button that executes the following code.

   var characterName:String;
   characterName = name_Input.text;
   //The next line was a solution I tried for this problem but it doesn't work
   characterName = characterName.split("\r\n").join("");

And on the next frame there is a trace to see what the value of that plus another variable is.

   trace(characterName+", the "+characterClass);

characterClass is automatically defined as "Default" so I can see if it worked properly. The trace is displaying the following:

   , the Default"

If anyone can help me figure out why the line break keeps showing up and how to prevent this, I would greatly appreciate it.

Also, if I hit the delete key before typing "Name" in the text box, it displays in line. So clearly the box has a line break in it automatically. I've already tried deleting and remaking the text box to make sure I hadn't accidentally added something to it.

Thanks in advance.

Make sure your Text Field is Single Line and not Multi Line in it's properties.

If that doesn't work, you can also try something like: yourstring.replace(String.fromCharCode(13), "")