# Line spacing in actionscript (typewriter effect)

**URL:** <https://forum.kirupa.com/t/line-spacing-in-actionscript-typewriter-effect/59142>\
**Category:** flash\
**Created:** [July 28, 2004, 7:25pm UTC](https://forum.kirupa.com/t/line-spacing-in-actionscript-typewriter-effect/59142 "2004-07-28T19:25:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbadmilkman](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@bigbadmilkman](https://forum.kirupa.com/u/bigbadmilkman)\
**Post date:** [July 28, 2004, 7:25pm UTC](https://forum.kirupa.com/t/line-spacing-in-actionscript-typewriter-effect/59142/1 "2004-07-28T19:25:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 12:48am UTC](https://forum.kirupa.com/t/line-spacing-in-actionscript-typewriter-effect/59142/2 "2004-07-29T00:48:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 29, 2004, 12:51am UTC](https://forum.kirupa.com/t/line-spacing-in-actionscript-typewriter-effect/59142/3 "2004-07-29T00:51:05Z")

</div>

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”

```auto

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

```

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

if you use two newlines, i.e.

```auto

  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”:

```auto

  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
