Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initTyper();
- function initTyper() {
- //Determine text to be animated and store in a new String object.
- textString = new String("MATT:");
- // Determine the length of the text in characters.
- charNum = textString.length + 1;
- // Declare a variable to count through the characters.
- theChar = 0;
- // Declare an array to contain each character.
- words = new Array();
- // Loop through every character and store character sequences into the array.
- for (i=0; i <= charNum; i++) {
- words[i] = textString.substring(0,i);
- }
- // Determine speed of text animation in milliseconds.
- typeRate = 10;
- //Establish the interval to call doTyper and animate the text sequences.
- typerLoop = setInterval(doTyper,typeRate);
- }
- //
- function doTyper() {
- // Compare the character counter against the total number of characters.
- if (theChar == charNum) {
- // Kill the function interval that's animating the text.
- clearInterval(typerLoop);
- } else {
- // Pass current array position value to the dynamic text field on the stage.
- ex_talk_box2.textContent.text = words[theChar];
- // Update the graphics on the stage.
- updateAfterEvent();
- // Increment the character count.
- theChar++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement