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
- CharlesSzentesi2 months agoCommunity Member
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!
- Nedim2 months agoCommunity Member
If each slide contains unique variables for its text, then it seems that those variables may not have been properly referenced on each subsequent slide. Your JavaScript code itself doesn’t contain any syntax errors.
I've reviewed your file and added an additional slide that uses the same code structure but with different variables, each correctly referenced. It works as expected.