Javascript interfacing question

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?

Hi John,

Is this what you’re trying to do?

random-card.saolapack (2.0 KB)

1 Like

it is! Many thanks for the quick response. I substituted a 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");"card" + rand);



1 Like