ActivePresenter Saola Animate Pricing Download

Text boxes Javascript

Problem:

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:
7.5.7

OS: Windows 7

Notes:

Hello,

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.

Regards,

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:
https://mega.nz/#!Ukl3RIwK!-eXmu4daEwOvVLy_yJmaThnTmm-GOyOxn_YZ81j3XD8

Hi,

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:

prez.object(‘Shape_3’).show();
prez.object(‘Shape_3’).hide();

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.
Regards,

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 ();
}else

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

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.

Hi,

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.

Regards

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() {
    this.hide();
    // stop attached audio
    this.animate(AP.EffectType.MEDIA_STOP);
    var nextIndex = parseInt(this.name().substring(namePrefix.length)) + 1;
    var nextObject = prez.object(namePrefix + nextIndex);
    if (nextObject) {
        nextObject.show();
        // play attached audio
        nextObject.animate(AP.EffectType.MEDIA_PLAY);
    } else {
        prez.nextSlide();
    }
};
var i = 1;
var obj;
while (obj = prez.object(namePrefix + i)) {
    ++i;
    obj.on('ap-click', clickHandler);
}