Jean-Philippe Murray
Jean-Philippe Murray

Reputation: 1248

How to add more then one space (whitespaces?) in a string?

I'm looking, for various almost mystical reasons, to have a string containing more than one spaces. Basically, I want to be able to have a text string that, when compiled into an SWF, will show "     ".

I'm sure it is possible but... How?

Upvotes: 1

Views: 1434

Answers (4)

Syed
Syed

Reputation: 79

This is an old questions but for future visitors here is the answer

use space between quotes and remember to add a plus sign between words.

For example

trace("Three spaces here" + " " + " " + " " + "Two spaces after this  ");

Remember that text is in quotes and variables are not. Anything between quotes is considered a String.

This is helpful to know when using dynamic text fields.

For example

this.some_text_field.text = String("I am" + " " + ageVar + " " + "years old");

The spaces can also be before or after text.

Hope that helps!

:)

Upvotes: 0

The_asMan
The_asMan

Reputation: 6402

I am pretty sure this would come down to the font you are using. Stringing spaces I believe tend to show up as 1 space. Try using a coding style font like Lucida Console.

Upvotes: 0

weltraumpirat
weltraumpirat

Reputation: 22604

If your string is within an xml document, you might want to set XML.ignoreWhitespace=true; and XML.prettyPrinting=false;

This will ensure that any whitespace (spaces, tabs and line breaks) are not compressed to a single space.

It also helps to have <![CDATA[ ]]> tags around your text, in some cases.

Upvotes: 1

Dr.Denis McCracleJizz
Dr.Denis McCracleJizz

Reputation: 870

You need to revisit some of the basics.

myString:String = " ";

myString:String = " " + " ";

myString:String = "        ";

Upvotes: 0

Related Questions