Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How can we Show-Hide or Enable-Disable Captivate Objects using javascript??

Explorer ,
Jul 14, 2015 Jul 14, 2015

How can we Show-Hide or Enable-Disable or change the color of the Captivate Objects using javascript ??

Any ideas, actually I want to avoid Advance Action type dropdown assisted programming and want to do text coding the actions.

TOPICS
Advanced actions , Editing
4.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jul 15, 2015 Jul 15, 2015

You can show/hide and enable using the following syntax.

cp.show("obj"+i)

cp.hide("obj"+i)

cp.enable("obj"+i)

cp.disable("obj"+i)

Translate
Adobe Employee ,
Jul 15, 2015 Jul 15, 2015

Hello,

This might help you in understanding the logic of show or hide objects.

Regards,

Rajeev.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2015 Jul 15, 2015

Hmmm, Rajeev. I looked at your document but cannot see how this can help the OP? He was not asking about show/hide using an advanced/shared action (have plenty of them on my blog) because he doesn't want to use advanced actions, with its point-and-click approach. He wants JavaScript to show/hide and enable/disable.

I can only point to the Help about JS: Common JS interface

This supposes you are using Captivate 8, because there was no common interface for SWF and HTML5 output in CP7.

And about show/hide vs enable/disable: be careful with shape buttons especially when they are timed for the rest of the project. Normally Hide will also disable an interactive object, and Show will enable it, but that is not the case for those shape buttons: you have both to Disable and Hide, or Show and Enable in several circumstances.

Just out of curiosity: why do you want to avoid advanced/shared actions? They are converted to JS on runtime. I can totally understand the use of JS for more complicated functions (where you embed the functions in the default JS file that you'll use in all projects) but why for these simple actions like Show/Hide and Enable/Disable. Especially now with shared actions?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2015 Jul 15, 2015

I have certain conditional actions emplaced in JS on the bases of the

values stored in SCORM VARIABLES, so it is just reiterating the logics in

the advance actions to hide and display the objects. If I do it by

transporting values from external interface. In addition to that similar

operations are to be applied on several objects, if these are named

properly like obj1, obj2, obj3 etc. They can be recalled in a loop in JS

like 'obj'+i

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2015 Jul 15, 2015

Thanks for explaining. Indeed if you need a loop, or need values from external interface, you have to turn to JS. However Hide/Show can be applied to a group of objects, just FYI. Too bad that at this moment you cannot Enable/Disable a group of interactive objects, one of my feature requests.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 15, 2015 Jul 15, 2015

You can show/hide and enable using the following syntax.

cp.show("obj"+i)

cp.hide("obj"+i)

cp.enable("obj"+i)

cp.disable("obj"+i)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2015 Jul 15, 2015

Thanks but cp.show() cp.hide() cp.enable() and cp.disable() work on HTML5

only. I need such for swf's as well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2015 Jul 15, 2015

So you dont need JS you need a solution with Actionscript.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 15, 2015 Jul 15, 2015

And I thought SWF was dead...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2015 Jul 15, 2015

Really, Flash is very alive! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 16, 2015 Jul 16, 2015

Hey guys;

Thanks for your support,

it was easier to convince the client for HTML5, than the designing advance

action. Just imagine how difficult would it be to make advance action for

the following function; including the transfer of values from JS to

captivate.

// JavaScript

function progress()

{

if (ip>0 && ip<4)

{

cp.show("I"+ip);

}

if (dp>0 && dp<11)

{

cp.show("D"+dp);

}

if (pp>0 && pp<11)

{

cp.show("P"+pp);

}

if (ep>0 && ep<4)

{

cp.show("E"+ep);

}

if (c==1)

{

cp.show("C1");

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 17, 2015 Jul 17, 2015

See I was right, flash was buried one more time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 18, 2015 Nov 18, 2015

TLCMediaDesign wrote:

You can show/hide and enable using the following syntax.

cp.show("obj"+i)

cp.hide("obj"+i)

cp.enable("obj"+i)

cp.disable("obj"+i)

I feel really dense, but I can't seem to get this to work. Any ideas what I might be doing wrong? I'm adding the Javascript to Edge Animate, packaging as OAM, then importing into Captivate. Depending on what happens in the animation, I want to show or hide various Captivate elements (e.g. captions).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 19, 2015 Nov 19, 2015

The OAM file is a child of Captivate. Try:

parent.cp.show("obj"+I)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 14, 2019 Jun 14, 2019

Hi there David,

what does the +i stand for in cp.enable("obj"+i)?

Thanks in advance

Bobby

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 14, 2019 Jun 14, 2019

The i is incremented in an iteration of a loop.

for ( var i=0; I < 4; i++ )

{

     I increments from 0 to 3

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 14, 2019 Jun 14, 2019

Thanks David

I wonder in what situation would I use that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 14, 2019 Jun 14, 2019

When you publish, there are no groups.

If you show or hide a group, Captivates output JavaScript does a separate show or hide for each element in the group.

If you name the elements you want show or hide with a sequential number:

SmartShape_1

SmartShape_2

SmartShape_3

SmartShape_4

You can then run a loop to access all of the elements.

A loop will generally not work in the Advanced Action JavaScript window because of the < sign.

There are other ways to run a for each loop, but you would need to get a reference to the elements you want to access a different way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 16, 2019 Jun 16, 2019
LATEST

Thanks David, I saw that JS would not work with groups.

This explains.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources