The project is like looking through Spaghetti…
Your problem by the looks of it is when in the code you first check the display of the photo group the returned value is “inline”. Not “block” or “none”
But your **if clauses ** is looking for display == “none” .
Because it is “inline” it goes to the else block of code and sets it to “none” . The next click then works.
To be honest I do not think you need the if clause any way and can get away with just setting things as you need them.
i.e
hypeDocument.getElementById('Sphoto201').style.display = "block";
hypeDocument.getElementById('Sphoto101').style.display = "none";
hypeDocument.getElementById('Sphoto301').style.display = "none";
hypeDocument.getElementById('Sphoto401').style.display = "none";
hypeDocument.getElementById('Sphoto501').style.display = "none";
hypeDocument.getElementById('Sphoto601').style.display = "none";
hypeDocument.getElementById('Sphoto701').style.display = "none";
hypeDocument.getElementById('Sphoto801').style.display = "none";
hypeDocument.getElementById('Sphoto901').style.display = "none";
hypeDocument.getElementById('vid01').style.display = "none";
hypeDocument.startTimelineNamed('photo201', hypeDocument.kDirectionForward)
No if clause.
If you wanted to cut down on code. You could just use one function that all the buttons trigger.
To do this you give all the photo groups in all the scenes the same class name.
i.e photogroup
Rename the timelines in each scene.
scene one’s stays the same Sphoto101 through to Sphoto901
scene two’s timeline names change to Sphoto102 through to Sphoto902 and so on with the other scenes.
In each scene you give the buttons the corresponding names that match the timeline it will run but without the “S”
i.e
scene one’s button ids will be photo101 through to photo901
scene two’s button ids will be photo102 through to photo902.
All buttons point to the same function which will work out from the buttons id and the scene name ( the last digit ) which timeline to run, which video to hide and which image to display to block.
var elID = element.id;
var photogroup = document.querySelectorAll('.photogroup');
for (i = 0; i < photogroup.length; i++) {
photogroup[i].style.display = "none";//-- this initially sets all the photo groups to none , from inline at the start. This is the simpliest place for it
if (photogroup[i].id === "S" +elID ) {
photogroup[i].style.display = "block";
}
var theVidID = "vid0" + hypeDocument.currentSceneName().substring( 5);
hypeDocument.getElementById(theVidID).style.display = "none";
hypeDocument.startTimelineNamed(elID, hypeDocument.kDirectionForward)
}
ebook-test-hypeForum01_MHv1.hype 2.zip (2.8 MB)
NOTE: I have removed the videos so I could post this back here. You will need to re add them…