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

Can I show and Hide objects based on current frame number

New Here ,
Jan 24, 2020 Jan 24, 2020

Hi is it possible to show or hide objects in captivating based on the current frame number through advanced actions? For example, I want to create an advance action that shows an object on stage when the play head reaches frame number 490,

TOPICS
Advanced actions
345
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
Community Expert ,
Jan 24, 2020 Jan 24, 2020

Perhaps explaining why you would want to do it this way might help use suggest a solution to your problem. Personally, if I wanted an object to appear on the stage at a very precise time I would simply place it on the timeline at that precise time. Far easier to do than writing advanced action (I could think about it for a while but I'm not certain how to have a frame number trigger an action in advanced actions).

Paul Wilson, CTDP
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
Community Expert ,
Jan 25, 2020 Jan 25, 2020

There may be a good reason to want this approach, but you didn't explain it.

Some ideas; use the Delay Command in an advanced action tirggered by the On Enter event of the slide. 

Or use JavaScritp where it is possible to create events for each frame.

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
Advisor ,
Jan 27, 2020 Jan 27, 2020

I will agree with the others that a little more context could help provide a more elegant solution.

Seems there is always many ways to accomplish the same goal.

The first one that popped into my head from a JavaScript standpoint would be to have an interval run onEnter to check the current frame and if it is equal to 490 show the object. In the example below I have a box on the stage named box that is hidden by default and extended on the timeline to accommodate 490 frames.

 

var showBox = setInterval(box490, 10);

function box490() {
if (cpInfoCurrentFrame==490) {
cp.show("box");
clearInterval(showBox);
}
}

 

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 ,
Jan 27, 2020 Jan 27, 2020
LATEST

You can execute this JavaScript in an Advanced Action or onEnter of the slide:

 

window.cpAPIEventEmitter.addEventListener("CPAPI_VARIABLEVALUECHANGED",function(){

if ( window.cpInfoCurrentFrame === 490 )
{
cp.show("Element Name");
cp.hide("Element Name");
}

},"cpInfoCurrentFrame");

 

Just change the "Element Name" to the names of the elements you want to show or hide.

 

Note that the cpInfoCurrentFrame is a running count throughout the project. You can add code to have it reset a count on each slide so you don't have to figure out the actual frame count, on slide 20 for example.

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