Finding out the name of custom behaviour event within a function

I am trying to work through my first project in Hype, and while I found solutions for most of my problems, there is currently a small stumbling block:

I would like to create Previous/Next buttons that go forwards and backwards through an array of “chapter” markers within a video (the video then skips to the active marker). I would like to use custom behaviours to trigger this, as the same buttons will be repeated in many scenes (albeit with different videos and different chapter markers). So I am looking at controlling this via one custom JavaScript function per video, where I define the chapter marker array and keep track of where we are inside the array.

However, I need to find out if the triggered custom behaviour is i.e. “Prev” or “Next” in order to increment or decrement the array position. Are the names of the custom behaviours passed through when calling a function? The event.type seems to only return HypeTriggerCustomBehaviour, and I can’t seem to find if there is another parameter which might contain the exact name of the triggered CB.

Thanks in advance for any tips.

The event has more than type.

You can use console.log(event) to see all keys.

The one you are looking for is

event.customBehaviorName

2 Likes

Ah, exactly what I was looking for. Works great.

Thanks for the tip about how to find out about further parameters for objects: I am sure I will be using that in the future as well.