Forum Discussion
Text typing effect using Javascript
It seems to be only an issue when viewing the whole project.I have multiple unique variables all set up in a similar way as the above example
The variable below appears on each slide, youre wiping the value before the slide starts.
// clear the initial value of the "TypingText" variable in Storyline
player.SetVar("Dog2", "");
You can try adjusting the project by creating 2 variables:
- Dog2_full (holds the full message)
- Dog2 (used for typing animation output)
var player = GetPlayer();
// Get the full message from a separate variable
var message = player.GetVar("Dog2_full");
// Reset the output variable
player.SetVar("Dog2", "");
var typingSpeed = 50;
var i = 0;
function typeWriter() {
if (i < message.length) {
var currentText = player.GetVar("Dog2");
currentText += message.charAt(i);
player.SetVar("Dog2", currentText);
i++;
setTimeout(typeWriter, typingSpeed);
}
}
typeWriter();
Duplicate you project file before trying above!