# Typewriter follow-up: Accessing the text

**URL:** <https://forum.kirupa.com/t/typewriter-follow-up-accessing-the-text/244049>\
**Category:** flash\
**Created:** [November 13, 2007, 10:43pm UTC](https://forum.kirupa.com/t/typewriter-follow-up-accessing-the-text/244049 "2007-11-13T22:43:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpann](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tpann](https://forum.kirupa.com/u/tpann)\
**Post date:** [November 13, 2007, 10:43pm UTC](https://forum.kirupa.com/t/typewriter-follow-up-accessing-the-text/244049/1 "2007-11-13T22:43:22Z")

</div>

In a previous post I asked how to render text letter by letter. Sumo provided a very nice solution with his Typewriter class, which I’m showing here: (Sumo, I replaced the setInterval call with a timer, and added some formatting)

```auto

package {
 
 // @usage: Typewriter(s:String, v:Number, t:TextField)
 // @param: s: String variable for the complete text
 // @param: v: speed in milliseconds, how often the interval is called
 // @param: t: textfield for the string (s)
 
 import flash.display.MovieClip;
 import flash.events.TimerEvent;
 import flash.text.TextField;
 import flash.text.TextFormat;
 import flash.utils.*;
 
 
 public class Typewriter extends MovieClip {
 
  private var sInt:Number;
  private var count:int;
  private var str:String;
  private var speed:Number;
  private var _textField:TextField;
  private var format:TextFormat;
  private var timer:Timer;
 
  public function Typewriter (s:String, v:Number, t:TextField):void {
   str = s;
   _textField = t;
   timer = new Timer(v);
   timer.addEventListener(TimerEvent.TIMER, writeIt);
   timer.start();
   count = 0;
   _textField.text = " ";
  }
 
  public function writeIt(e:TimerEvent):void {
   format = new TextFormat();
   format.font = "FFF Alpine";
   format.size = 8;
   format.bold = false;
   format.color = 0x890025;
   _textField.width = 200;
   _textField.height = 500;
   _textField.wordWrap = true;
   _textField.text = str.substring(0, count);
   _textField.setTextFormat(_format);
   count++;
   if (count > str.length) {
    clearInterval(sInt);
   }
  }
 } 
}

```

Here’s my next problem. After defining my text string t in my .FLA file and passing it to Typewriter thus:

```auto

var type = new Typewriter (t.text, 3, t);

```

… I now want to be able to access t to change formatting (font, bold, etc.). But I cannot get this to work:

```auto

t.replaceText(15, 15, "[inserted text]");

```

What do I need to change to gain access to the text rendered in the Typewriter class?

Thanks!
