Text boxes Javascript


I would like you to help me create a javascript where I can have 4 rectangles and when I click on the first one, the second one appears and the first one is hidden and so on.
Sorry about my English.

ActivePresenter Version:

OS: Windows 7



To create a project having 4 rectangles which are shown and hidden in turn when you click one of them, simply set the events-actions for these 4 shapes as the enclosed project:

4 rectangles.approj (188 KB)

Below are specific steps for doing that:
Shape 3: You need to add Show Object action to show Shape 4 and Hide Object action to hide Shape 3.

In the Properties pane > Interactivity > Events-Actions > Add event > On Click:

  • Add Show Object action > Shape 4 and deselect the Hide After and Blocking check box in the dialog.

  • Add Hide Object action > Shape 3. Deselect the Blocking check box in the dialog.

Apply the same steps for the rest rectangles.

For Shape 4, Shape 5 and Shape 6 not being shown at first, select them all then right-click > Initially Hidden.


Hi. Good morning.
I had already done that process, but using a lot of slides and text boxes is too much work. I need something like a script which provides me with a counter that shows the next text box and hides the current one.

It is possible?

As I can’t upload, follow link:


In such complicated project like yours, using javascript can help you save some time. Here are 2 lines of code used to show/hide an object that may be useful for you:


You just need to add the Execute Javascript action to On Click event of each shape. Then paste the 2 lines of code above, and adjust the appropriate object.

For other objects, just copy the events-actions of one shape and paste to others; and adjust the object name appropriately.
Below is a screenshot for doing that.

Hope this will help.

Hello Good morning. The click function works, but the audio in the rectangle is not playing as it moves to the next.
Sorry to bore you, but I’m breaking my head to do it.

I would like something generic like:
If click on object_1 then do: {}
Else If click on object_2 do: {}
Else if click on object_3 do: {}

So that it can be used on all rectangles without the need for alteration.

if (prez.object (‘caixa_1’).show) {
prez.object (‘caixa_2’). show ();
prez.object (‘caixa_1’). hide ();
} else

if (prez.object (‘caixa_2’).show) {
prez.object (‘caixa_3’). show ();
prez.object (‘caixa_2’). hide ();
} else

if (prez.object (‘caixa_3’).show) {
prez.object (‘caixa_4’). show ();
prez.object (‘caixa_3’). hide ();

if (prez.object (‘caixa_4’).show) {
prez.object (‘caixa_5’). show ();
prez.object (‘caixa_4’). hide ();

if (prez.object (‘caixa_5’).show) {
prez.object (‘caixa_6’). show ();
prez.object (‘caixa_5’). hide ();

Something like that, but when I put it, besides not touching the audios it stops at the second rectangle and does not go forward.


Please see the script in On Load event of the first slide in this sample: test_box_text.approj (1.4 MB)
Please be noted that attached audio is not played/stopped automatically when showing/hiding an object by script. You must invoke a function to play/stop it.


Hello good day.
Thanks for the help, it worked perfectly!

Is there any way not to tell how many boxes are on the slide? I say, make an accountant?

Please use this updated script:

// update namePrefix
var namePrefix = 'caixa_';

var clickHandler = function() {
    // stop attached audio
    var nextIndex = parseInt(this.name().substring(namePrefix.length)) + 1;
    var nextObject = prez.object(namePrefix + nextIndex);
    if (nextObject) {
        // play attached audio
    } else {
var i = 1;
var obj;
while (obj = prez.object(namePrefix + i)) {
    obj.on('ap-click', clickHandler);

Hello good day

After a while using the current script, I would like to make a change.
Place 2 buttons, forward and backward.
Where one goes to the next box and the other goes back to the previous one.
Is there any way to do this?

Follows model for test


Please see the script in Project Properties > Event tab teste.approj (1.5 MB)


Thank you. It’s working better than I imagined.
But not wanting to abuse … Is there a way to only change the box if the audio is finished?

Unfortunately, it’s not possible with the current version of ActivePresenter.
We’ll try to improve it in the future.