Javascript in masterslides

Hi,

I use AP to create learning games - much like adventure games.
I use a master slide to create an inventory of objects. The objects show up in the other slides depending on whether they have already been found our not. For each of the slides of my game I now use a little bit of JavaScript to show the obejcts that have been found. It is the same code for each slide and I was hoping that putting this piece of code in the master slide would make the use of the code in each individual slide unnecessary. It did not work though. Can you tell me whether it is possible to do something like this, or maybe use an advanced action in the master slide.

Thanks,

Rolf

Hi Rolf,

Please make sure names of objects you used in your code are unique on a slide (including the master slide and the layout that slide uses).

Regards

Thanks for your reply.

I think I do that. Just to make things clear.

There is an object in the master slide called KeyGreen. The object is initially hidden in the master.
On each of the slides I use the following code line:

if(prez.variable(‘KeyGreenFound’) && !prez.variable(‘KeyGreenUsed’)){
prez.object(‘KeyGreen’).show();
}

This line of code works on each of the 30+ indiviual slide. However, if I put this line in the slide master and delete it from the other slides, the line of code does not work.
Where is the mistake?

Thanks,

Rolf

Hi Rolf,

By default, normal slides will inherit and show actions in the master slide.
Maybe you deleted actions in normal slides before adding actions to the master slide, so normal slides didn’t inherit actions from the master slide anymore. Another possibility is that you deleted the inherited actions.
Now you should select each normal slide, select slide name in Properties > Events-Actions, and click Reset Event:

image

Regards

Thanks, Toan, works fine now! Best, Rolf