Pause Scene's main timeline with button in persistant symbol


I constructed a project with 3 scenes, which automatically jump from one to the next every two seconds. I have a persistant symbol which contains buttons to jump ahead one scene, jump back one scene and stop. The first two work as intended, the stop button never works. Is it not possible to just stop a timeline?

See file attached. (25.9 KB)


which automatically jump from one to the next every two seconds.

In the example Hype document you provided nothing happens when I Preview the project - nor do I see a mechanism on either the persistent symbol’s “Main Timeline” or the projects “Main Timeline” that would do what You describe.

Same result when I click an “Ahead” ~ “Back” button - it jumps to the next~prev scene, but then no auto advance (perhaps this was not intended anyway).

Overall there is nothing for the “Stop” button to stop that I could find.

Note: I withdrew a post on another topic of yours because the question appeared identical.

(Mark Hunte) #3

You set up is basically correct.
The only thing you are missing is there is nothing to stop on the timeline. You do not have any animations of elements or actions doing anything. The timeline is blank. So I am not sure what you are expecting to see stopped ?


Thanks for your replies. I had forgotten to put timeline actions in each scene so I’ve fixed that in the example below, but I still can’t get the main timeline to stop. Clicking the Stop button doesn’t do anything though I’ve added an action to “Pause the Main Timeline” in the actions pane. See updated file attached.

buttontest (26.5 KB)

(Mark Hunte) #5

When you use a symbol, the Actions are relate to that symbol timelines. i.e the Symbol’s main timeline.

You could create a Custom Behaviour which pauses the Main Time on the scene and then from the symbol trigger the Custom Behaviour.

But you have three scenes and the Custom Behaviours if I remember correctly will not work for each scene in this way.

(Be nice if they did via an option to become global)

So the easier thing for you to do is just have the Stop button call a Javascript function that runs.

hypeDocument.pauseTimelineNamed('Main Timeline');

This will work on what ever is the current scene.


Here is your demo utilizing both your persistent symbol button set with (3) Custom Behaviors for the “Stop” button and @MarkHunte’s JavaScript suggestion (I know You do not like JavaScript but please read the whole post).

buttontest 2 (38.6 KB)

Each Custom Behavior stops the “Main Timeline” of the project (as opposed to the “Main Timeline” of the symbol) for the corresponding Scene (set in the “Scene Inspector”).

The “Stop” button in the persistent symbol triggers all three Custom Behaviors.

Then, as previously mentioned, we have the JavaScript solution - one teeny weeny itsy bitty line of code - that makes things so much simpler and far more flexible than the Custom Behavior approach.

This JavaScript code is triggered by the button called “Stop JS” (a persistent symbol) which then runs the JavaScript “stopMainTimeline()” which appears in a tab over the Animation pane.

As You can see this JavaScript approach is simple (just copied and pasted @MarkHunte’s code) - and yet far more flexible than the Custom Behavior technique which requires a new corresponding Custom Behavior every time You create a new Scene. With the JavaScript solution You do not even need to think about it - just create your Scenes and the “Stop” button will work for all of them.


For Extra Credit:

The code that Mark provided is easily created using Hype’s API.

In the image below is the JavaScript Editor which shows up when You click the forementioned “stopMainTimeline()” tab. There You will see at the bottom the blue highlighted line “hypeDocument.pauseTimelineNamed()”. Double click that and it is added to your code above in the JavaScript Editor. Then You just need to fill in the name of the timeline You want to pause - in this case the “Main Timeline” (for the project).

It’s actually easy, and it’s the right tool for the job.