Javascript not working after jump to scene

In the attached file, if you select path option a and path Diagram (455.6 KB)option c, a timeline will fire that reveals some of the path.

if you click path option a or path option c again, the scene will jump back to its start point, but the a + c selection no longer works, instead, as soon as you select a, the timeline fires.

any suggestions would be a great help,
Diagram (455.5 KB)

Thats because you have a ‘trigger scene reset’ element over the button that becomes visible on timeline ‘button 1 click’

thanks mark, i tried removing the trigger scene reset element, only keeping the one that appears over button C, but still after the animation jumps to the start of scene, as soon as A is clicked, it ignores the A && C true if statement and fires the AE cloud timeline anyway

can you think of a way it would be possible for timeline AE cloud to return to its beginning once A OR E are toggled off ?

Hava a look at using Custom behaviours.

For example you can set a New Custom behaviour on the Main Scene, that ‘Go to time in Timeline, AE Cloud, 00.00.00’

then in the Symbol Element 1, have the trigger scene reset run the custom behaviour ( just put in the same name you used) and another action to ‘continue timeline, button click 1’

This is how you can access timelines between scene and symbol timelines.

You have too much already setup for me to do and example I am afraid. So this is a rough idea and you would need to consider all your buttons to work together.

1 Like

Your variables on scene load are not being recognised in your other functions because they are not global. So your if/else function cannot establish the variable ButtonA. If you make the variables global then they can use them.

so instead of

var ButtonA = "....


window.ButtonA = "...

Also, Mark makes a compelling argument above. Look into custom behaviours.

thanks for the advice,
changing the variables on scene load has solved the problem

@MarkHunte, that makes sense I’m going to set up a simplified version for the template gallery, will prob come in handy for other people working on projects with toggles.

In the file I attached, I wanted the Ae cloud timeline to continue/go to beginning based on what the toggle buttons were doing visually, so I initially tried to control Ae cloud timeline using timeline actions in symbol 1 and 2 to make values false/positive. Is this possible?

Just to add a bit more information …

When using, for example,

var something = "...

then the variable is stored only for that script / function and nothing outside the script / function can access that variable. It’s like a temporary assignment. When you’ve finished the ‘action’ (script / function) the name of the variable is put back in the pool so it is available.

When using the

window.something = "... 

then the variable is held by the browser (window) and can be used as and when (also in the console) and will only be released at the end of your session. (well, never as when you open back up it will be stored again :slight_smile: )

You can also use the Hype API to start, pause, rewind

hypeDocument.startTimelineNamed('**timeline**', kDirectionReverse / kDirectionForward)
hypeDocument.pauseTimelineNamed('**timeline**') // pause
hypeDocument.goToTimeInTimelineNamed(0, '**timeline**') // rewind to beginning

var currentTime = hypeDocument.currentTimeInTimelineNamed('**timeline**')
hypeDocument.goToTimeInTimelineNamed(currentTime - 2, '**timeline**') // rewinds the timeline 2 seconds 

… timelines so perhaps in your code already you can check the state of the toggled buttons and maybe manipulate the timelines accordingly.