Copy link to clipboard
Copied
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.
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)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Thanks but cp.show() cp.hide() cp.enable() and cp.disable() work on HTML5
only. I need such for swf's as well.
Copy link to clipboard
Copied
So you dont need JS you need a solution with Actionscript.
Copy link to clipboard
Copied
And I thought SWF was dead...
Copy link to clipboard
Copied
Really, Flash is very alive!
Copy link to clipboard
Copied
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");
}
}
Copy link to clipboard
Copied
See I was right, flash was buried one more time.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
The OAM file is a child of Captivate. Try:
parent.cp.show("obj"+I)
Copy link to clipboard
Copied
Hi there David,
what does the +i stand for in cp.enable("obj"+i)?
Thanks in advance
Bobby
Copy link to clipboard
Copied
The i is incremented in an iteration of a loop.
for ( var i=0; I < 4; i++ )
{
I increments from 0 to 3
}
Copy link to clipboard
Copied
Thanks David
I wonder in what situation would I use that?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks David, I saw that JS would not work with groups.
This explains.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now