I edit the above post,
I downloaded the file but did not realise I clicked on my older one, so thought you sent me the old one back with no changes. Proceeded any way to add scenes and change the code, as I was in the middle of editing the posting with the fix I realised my mistake.
Any way I have now adjusted the new one.
First we need to only get the buttons for the current scene.
We add the line :
var thisScene = hypeDocument.getElementById(hypeDocument.currentSceneId())
and change:
var buttons = document.querySelectorAll('.button');
to
var buttons = thisScene.querySelectorAll('.button');
And while we are at it lets give all the comp elements the class name comp_ and then change:
var comp_A = hypeDocument.getElementById('comp_A')
to
var comp_ = thisScene.querySelector('.comp_')
we also change the line
let selectedEl = document.querySelector('.button[data-selected]');
to
let selectedEl = thisScene.querySelector('.button[data-selected]');
So above we are only dealing with elements on the current scene.
I removed the number 2 from any attribute names and button class names . The Attribute name ALL need to stay the same across scene buttons. We do not use IDs. ALL buttons have the same class name button
All of the above allows us to just use one Hype function without having to duplicate for each scene.
Each scene now point to > SelectDisplay()
You will also notice a (hack) function named Selected().
This runs on all scenes On Prepare For Display
The intent of this function is to retain each scenes selection across scene backward and forwards.
We also add the line
hypeDocument.customData[hypeDocument.currentSceneId()] = element
in SelectDisplay() to set globally which button was selected in each scene. Which is then accessed in Selected()
If you do not need this last bit to happen just remove the On Prepare For Display*
EZY-Color-v5-outros-elementos-MHv2.hype.zip (1.8 MB)
--
Also the scene selection buttons.
I would change them to use code for the mouse over/out as we have done with the selection buttons.
As I said above if you use the UI button hover in Hype they will not work as expected and stick.