Skip to main content
Inspiring
October 28, 2019
Answered

Typewriter Effect using apendText that can shift the body of text up as new lines are added

  • October 28, 2019
  • 1 reply
  • 308 views

I'm simulating a computer typing on code - I've got a rather long string that's typing on using apendText (script below).  My problem is that when my text reaches the border of the dynamic text field it stops displaying.  I need the size of the text field as it currently is for design purposes.

 

I'm wanting the text to continue to type on at the bottom line of the Dynamic text field and shift the previous lines up for each new line that's typed on.  Hopefully what I'm trying to accomplish makes sense.  

 

I also want my string to loop infinately so the same block of code starts over after the last line of the previous loop.


Thanks in advance for your help!

 

var myString:String =" long text string here...";

var myArray:Array = myString.split("");



addEventListener(Event.ENTER_FRAME, streamingCode);

function streamingCode(event:Event): void {

if (myArray.length > 0) {

myCode.appendText(myArray.shift());
}

 

    This topic has been closed for replies.
    Correct answer kglad

    to do a really good job will require more work than is suitable for a forum fix. 

     

    but you can get started by using a multline textfield that you create with the single line height you want.  then as the text is being added to the text field repeatedly check for the textHeight.  once it increments,  the previous text should be removed and the text starting at the textHeight increment should be added to the textfield.  repeat as needed.

     

     

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    October 29, 2019

    to do a really good job will require more work than is suitable for a forum fix. 

     

    but you can get started by using a multline textfield that you create with the single line height you want.  then as the text is being added to the text field repeatedly check for the textHeight.  once it increments,  the previous text should be removed and the text starting at the textHeight increment should be added to the textfield.  repeat as needed.