How can I trigger an action based on a specific variable value?


(Marko Proteau) #1

Hi.
First, my apologies in advance, I’m new to javascript so I might be asking a super stupid question. :slight_smile:

I’d like to program some actions to change global variable values, so that then other actions could trigger specific timelines depending on the variables values.
I did my best going through this forum, but unfortunately I’m getting nowhere :frowning:

I’m pretty sure the solution is pretty obvious for you guys. That would help me a lot if anybody could help me with this !

I’ve attached here an example of what I’m trying to achieve.Conditional Scene Jump.hype.zip (38.2 KB)

Tkx in advance for any help everybody !


#2

The Hype API that seems related to your issue is…

hypeDocument.goToTimeInTimelineNamed(timeInSeconds, timelineName)

So, the JavaScript might be something like this…

if (x == 2) {
hypeDocument.goToTimeInTimelineNamed(2, "Main Timeline");
}

(Greg) #3

Hi Marko, your script works fine except that your if statements are typed in with an UpperCase I…

If vs if

Use lowercase and all is well

if (SceneChoice == 2)    versus    If (SceneChoice == 2)// capital I will error
also   else if    not    else If

(Marko Proteau) #4

YOU MAKE MY DAY !!
Tkx tkx tkx tkx !

I had the feeling it was something stupid like that, but I honestly didn’t think this would be the reason. :slight_smile:
Like Yoda says : Still much to learn, I have. :slight_smile:

Tkx again Greg, I appreciate so much and I can now complete my project !

Marko