Line spacing in actionscript (typewriter effect)

I’m trying to do a typewriter effect, now i’ve done that , but i want to be able to space my text instead of having a block of text. eg

Text 1

Text 2

etc, u get the idea, how do you do line spacing in actionscript? This is the code I have at the moment

myText = “”;
this.onEnterFrame = function() {
text.text = myText.substr(0, type);
type += 4;
myText = (" hello hello ")

};

Any help would be appreciated!

Thanks

Either use a carriage return (\r) or a line feed (
). :slight_smile:

There’s two ways to do this, one easy but weak, one slightly more difficult but powerful.

easy/weak way:

in a normal textbox (not htmlText) you can do the equivalient of pressing the Enter Key by using “newline”


  mytext = "hello" + newline + "world";
  mytextbox.text = mytext;
  

produces:
|========================| |
| hello
| world
|
|========================| |

if you use two newlines, i.e.


  mytext = "hello" + newline + newline + "world";
  

you will produce:
|========================| |
| hello
|
| world
|========================| |

That’s the easy way. If you want even more control, you’ll have to use textFormat;

textFormat, in case you’ve never used it, is a flash object used to control complicated text formatting.
It has a property called “leading” which controlls the amount of vertical space between lines. For example, let’s say you have a dynamic multiline textbox on your stage called “myTextBox”:


  myFormat = new TextFormat();
  myFormat.leading=20;
  myTextBox.text = "hello" + newline + "world";
  myTextBox.setTextFormat(myFormat);
  

will put 20 pixels of spacing between each line.
Don’t think this works with htmlText however.

Hope this helps,

–EP