# Typewriter text problem

**URL:** <https://forum.kirupa.com/t/typewriter-text-problem/97527>\
**Category:** Uncategorized\
**Created:** [December 23, 2003, 7:44pm UTC](https://forum.kirupa.com/t/typewriter-text-problem/97527 "2003-12-23T19:44:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [December 23, 2003, 7:44pm UTC](https://forum.kirupa.com/t/typewriter-text-problem/97527/1 "2003-12-23T19:44:35Z")

</div>

Another hour, another thread, heh heh . . . . heh

Heh?

Well, I am using the following typewriter text effect on the first frame of my main timeline:  
[AS]  
myText = “”; // text box is empty to start  
this.onEnterFrame = function() {  
MCtxt.text = myText.substr(0, type); // set the length of the string to the length of the type  
type += 1; // keep increasing type until all of text is printed  
var c = (myText.length-MCtxt.text.length); // create variable c to decrease as string is output  
myText = “blah blah blah, yadda yadda yadda.”;  
if (c == 1) {  
\_root.movie\_close.gotoAndPlay(2); // when all of text is out play animation  
}  
};  
[/AS]

I set the variable c to count down to the end of the effect so when it “prints” the last letter it triggers an animation of an arrow moving across the stage. The arrow animated movie clip is 240 frames long. When it gets to frame 120 I want it to stop which it does. Then I want to clear the text box and “print” something different. I want to use the same effect as above - when it gets to the last letter it goes to frame 121 and continues with the rest of the animation.

So on frame 120 I have this:  
[AS]  
stop();  
thisText = “”; // text box is empty to start  
this.onEnterFrame = function() {  
\_root.MCtxt.text = thisText.substr(0, type2); // set the length of the string to the length of the type  
type2 += 1; // keep increasing type until all of text is printed  
var d = (thisText.length-\_root.MCtxt.text.length); // create variable c to decrease as string is output  
thisText = “more text blah blah blah.”;  
trace(d)  
if (d == 1) {  
gotoAndPlay(121); // when all of text is out play animation  
}  
}; }  
[/AS]  
The trace returns the correct number and when it reaches 0 it triggers the next phase of animation, but the text does not “print.” If I add \_root to “thisText” then it does print but it prints all at once instead of doing the typewriter effect. What am I doing wrong?
