• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Participant ,
Oct 28, 2019 Oct 28, 2019

Copy link to clipboard

Copied

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());
}

 

Views

189

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 29, 2019 Oct 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.

 

 

Votes

Translate

Translate
Community Expert ,
Oct 29, 2019 Oct 29, 2019

Copy link to clipboard

Copied

LATEST

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.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines