I have a very simple Javascript function which generates a random number (let’s call it randNo). In my Scene I have 3 labels – card1, card2, and card3. How can I concatenate the string “card” with the variable randNo so that an onClick event willl go to one of 3 random labels?
I can’t figure out a way of interfacing the Javascript code with the inner workings of Saola Animate…
Is there a way?
it is! Many thanks for the quick response. I substituted a doc.play at the end, and it worked! Thanks for your time – appreciate it.
In the spirit of sharing, here is the code for jumping to random labels
picked from “card1”, “card2” and “card3” (with thanks to mackavi):
function showRandomCard(doc, e) {
var rand = Math.floor ((Math.random() * 3) + 1);
var current_Timeline = doc.getTimeline("your timeline here");
current_Timeline.play("card" + rand);
}
Enjoy!
J.
1 Like