Global variables for timeline

Hello,
I’m a javascript newbie. I have tried to find solutions in the forum, but I would appreciate help.
It’s about several sliders that set values. These values should be kept over several scenes and displayed in other scenes. I’m not sure if “window” is the right choice here. In addition there are presets, (I had them done in the HEAD), which should bring the sliders in different scenes to the default position as well as display the corresponding value.
I can’t manage to keep the values from scene 1 and I can’t set the slider to a defined position so that the slider remains movable.
(The sum object is not important, I took it from an example from the forum)
Any suggestion is welcome. Thanks

global_variables_for_sliders_02.hype.zip (40.1 KB)

Hype has an API which you can store in it’s scope globals.
hypeDocument.customData There are plenty of threads already that explains how to…

The were a number of mistakes in you code, like if( element)...
That always going to be true.

Anyway,
This is not perfect but it works…I really try and not to change peoples code too much when they are learning as it could get too confusing if it does not contain most of their logic.
you’re likely going to have to muddle through my changes…

( note I also increased duration of the slider 2 timeline to work better with the math logic )

MHv1_global_variables_for_sliders_02.hype.zip (64.0 KB)

3 Likes

Thank you Mark,

you were right, I had to muddle through your changes.

I have now added another scene with another slider. At first everything went right.

Then I created a menu to navigate to all scenes. To be honest, there are some things I probably don’t understand yet, because I couldn’t get all sliders to be in the right positions (the lower slider in scene 1 won’t…).

Also, you can now swipe between all scenes - and here new problems arise: Even if the sliders could be controlled successfully by script in the button press, if the transition is still running, you still see the 0-values. The values are set correctly as soon as the scene is locked in. Unfortunately the one slider still does not…

Probably you would have to program this completely different?

MHv1_global_variables_for_sliders_07_menue.hype.zip (79.9 KB)

Hmm,

I think I will have something that will work but I will need to build it from the one I posted.
There will be some cheating in it to solve the 0 values ( I hope ) . known issue , due a transitions does not = scene loaded, but an instant transitions makes it look like it…

There is a clue in that that will let us cheat.

And if you thought muddling through the last one was a head…f… then just wait…

Sorry, got waylaid. I have one that all slides work. But will have to post it later.
The cheat I was talking works to an extent but not working that great So that bits not in it.
Also I changed how the timelines for drag left-right for page slides work. ( scenes only, no duplicates on scene.)

Hi, sorry for not responding,
I have been offline a few days.
I am very curious how this will work and hope there will be more to come.

Ok.

The main changes are how the drag works.

Here is the one with the transition fix. ( which was annoyingly simple to fix )

We only have scenes. (No duplicates of scenes on each scene)

Each scene’s elements are in a group.
The group has a drag action on it.
The drag action runs a function to set the hypeDocument.customData.actionElement value to 'dragToScene’

( When the slider functions run, they check for this value to see if we are dragging or using the back button. )

The drag action also controls the scenes timeline named drag.
The drag timeline has two timeline actions.

The first timeline action. is placed at 0s

The second timeline action. is placed at 2s

On scene load each scene will be told to go to 1s in timeline drag . ( i.e in the middle of the timeline actions)

scene 1’s timeline actions. are set to.

The first timeline action . = 'pause timeline drag
This stops any drags to the left activating scene change.

The second timeline action. = next scene push right to left

scenes 2’s timeline actions. are set to.

The first timeline action . = next scene push left to right

The second timeline action. = next scene push right to left

scenes 3’s timeline actions. are set to.

The first timeline action. = go to next scene push left to right

The secondtimeline action . = 'pause timeline drag
This stops any drags to the right activating scene change.

All of the timeline actions. that push to scene also run the previous/next scenes slider code.
That one small bit fixes the transition issue. As it sets up the scene as before transitions.

I ams sure I knew this and forgot we could do this and just re figured it out… as I said annoying.
I vaguely remember that this should not work?.
( I actually made a symbol version that was not really needed in the end. )

global_variables_for_sliders_MHv4.hypetemplate.zip (72.4 KB)

2 Likes

Hi, Mark,
Thank you very much for the very detailed explanation. Now it works almost as desired. I like your transition fix.

I had decided on the cumbersome and labour-intensive wiping of the scene over the timeline (which you have replaced), because at the end of the day a menu and other parts of the GUI always stay in the same place and should not be wiped sideways together with the content of the slider.

But the pushing transition between the scenes doesn’t allow this or is there a trick?

Your Menu symbol should work. It should be set to display on top od transitions and be persistent across scenes.

You would just need to set up the buttons with the correct actions and adjust any code in the slider functions so it knows the call is coming from a button.

1 Like

FANTASTIC - I did not know what permant symbols have been for, now I know it. Thats brilliant. Thanks for that little nudge.

All Problems in this thread solved.

3 Likes