Js execution every time slide is visited

Hi

I use on slide load

prez.variable(‘slideIndex’, prez.currentSlideIndex());
if (prez.variable(“slideIndex”) == 1) {
prez.object(‘page_01’).fillSolid(prez.variable(“pagination_color”));
};

works fine the first time the slide is displayed but if I navigate through the other slides and come back, it’s not working until I reload the browser window. If I add ?slide=1 to url it’s working.

Thanks,
Marcel

Hi,

Your script is correct but if you see it doesn’t work, it’s likely that the pagination_color variable stores an invalid color. Please recheck it.

In addition, there are some notes as follows:

  • If you have already used prez.currentSlideIndex(), there is no need to save it to the variable.
  • If you want to use variables, ActivePresenter also has apCurrentSlideIndex

Regards,

1 Like

@zweitsprache -

When I am troubleshooting these sorts of things, I like to create what I simply call troubleshooting boxes. These are nothing more than shapes on the screen to display my variable values for me.

In this case, I might create a shape and place %pagination_color% as the text so that I can track what the project believes the value to be. When you return to the slide you can see what the value is and react accordingly.

This will allow me to know if my values are changing the way that I expect them to.
Create as many boxes for as many variables as you need. You can delete them as soon as you have figured it all out.

Hope that helps.

1 Like

Thanks for the variable, didn’t think of it.
M

Hi Greg

That’s what I do :wink: and I get the correct values, seems to be an issue with view slide load and button states. I’ll try another approach with states, but I’m not sure yet if works for a page numbering on slide template.

Marcel