Advertisement
Guest User

Untitled

a guest
Jun 6th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. initTyper();
  2. function initTyper() {
  3.     //Determine text to be animated and store in a new String object.
  4.     textString = new String("MATT:");
  5.     // Determine the length of the text in characters.
  6.     charNum = textString.length + 1;
  7.     // Declare a variable to count through the characters.
  8.     theChar = 0;
  9.     // Declare an array to contain each character.
  10.     words = new Array();
  11.     // Loop through every character and store character sequences into the array.
  12.     for (i=0; i <= charNum; i++) {
  13.         words[i] = textString.substring(0,i);
  14.     }
  15.     // Determine speed of text animation in milliseconds.
  16.     typeRate = 10;
  17.     //Establish the interval to call doTyper and animate the text sequences.
  18.     typerLoop = setInterval(doTyper,typeRate);
  19. }
  20. //
  21. function doTyper() {
  22.     // Compare the character counter against the total number of characters.
  23.     if (theChar == charNum) {
  24.         // Kill the function interval that's animating the text.
  25.         clearInterval(typerLoop);
  26.     } else {
  27.         // Pass current array position value to the dynamic text field on the stage.
  28.         ex_talk_box2.textContent.text = words[theChar];
  29.         // Update the graphics on the stage.
  30.         updateAfterEvent();
  31.         // Increment the character count.
  32.         theChar++;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement