Custom behaviour or javascript to save a lot of repetition

Hello fellow Hype fans!

Just a quick question that would save me a lot of repetition. Tile A is pressed and pops up and is pressed again and pops back down, great! I want all the tiles to do the same (in reality I have lots and lots of tiles that need to do this). I really don’t want to have to repeat a timeline for each tile and I was wondering if there was an easy way to do this with either a custom behaviour or a simple JS function. My small brain can’t figure it out but I was wondering if someone out there can solve this to save me hours of repetitive awfulness. I have attached a hype doc to illustrate my conundrum. Thanks in advance! tile pop.hype.zip (10.5 KB)

Hi, why don´t you use Symbols? Just add the ‘button pop’ timeline to a symbol, add the ‘continue symbol timeline’ action and continue the timeline by clicking the symbol. You can add the letter referring to each symbol-instance (or do other symbol specific things…) by calling a little javascript onLoad of the symbol (using the HTML-Attribute feature)

image

Hope,this helps, regards
Kalle

tile pop.hype_v1.zip (17.1 KB)

1 Like

Love it! Thank you so much for your time and perfect solution (and saving me loads of time!)

oh hang on. I’ve hit a problem as I needed the tiles to have different images on them rather than text - sorry, I know this was not clear in my example. Is there an easy solution to this?

Well, without having tested … you can load images dynamically (look at this thread e.g.) You can set the url to the image as an HTML-Attribute (like I did it with the letters)

Thank you so much for this help. That’s a lot for my novice brain to get around. I’ll give it a go.

Works pretty well… :wink:

bgpicture.zip (33.9 KB)

1 Like

I added the background images to the library. ‘data-picture’ is the name of the picture to load:

Bildschirmfoto 2020-06-23 um 17.40.31

"${resourcesFolderName}/" + symbolInstance.dataset.picture);
… is the combination of path to the resource folder and the picture name (data-picture in HTML-Atributes)

2 Likes

Absolutely incredible. Thank you so much. That really is a HUGE help!

1 Like