Skip to main content
Inspiring
March 20, 2017
Answered

JavaScript: Get property of object

  • March 20, 2017
  • 1 reply
  • 773 views

Hi,

I've got the following question:

I want to hide all objects on a slide that are not shown "For Rest of Projects". I get all elements of the current slide with e.Data.si (using the Slide Enter Event). These elements include the objects set to display for the rest of project. How can I decide for each of these objects whether it is set to display for the rest of project or not?

I'm using Captivate 9 (most recent version) and publish in HTML5.

Any help is greatly appreciated! Thank you very much in advance!

    This topic has been closed for replies.
    Correct answer sdwarwick

    You can get the start and end time for each shape in JavaScript by using the shape ID.  First you need the frame rate, which defaults to 30 frames per second and is set in the "Project Preferences"

    Assuming the shape ID is "SmartShape_1"

    The variable:   cp.D.SmartShape_1.from  is one plus the frame number that the shape is scheduled to appear.  

    The formula for this number is:  (number of seconds from start of the entire module * 30 ) +1

    The variable:   cp.D.SmartShape_1.to gives the frame number where the shape disappears.  For shapes that are shown for the "rest of the project"  this will be the last frame number in the project.  

    The variable cpInfoFrameCount  gives the number of frames in the project,  so you can identify shapes that are set to "end of project" by just checking which ones have a "to" variable the same as this cpInfoCount value.     Note that the last slide of the presentation should be blank with a 1 second play time to ensure that there is a distinction between shapes that are shown on the last presentation slide and ones that are set for "rest of project"

    1 reply

    sdwarwickCorrect answer
    Participating Frequently
    March 23, 2017

    You can get the start and end time for each shape in JavaScript by using the shape ID.  First you need the frame rate, which defaults to 30 frames per second and is set in the "Project Preferences"

    Assuming the shape ID is "SmartShape_1"

    The variable:   cp.D.SmartShape_1.from  is one plus the frame number that the shape is scheduled to appear.  

    The formula for this number is:  (number of seconds from start of the entire module * 30 ) +1

    The variable:   cp.D.SmartShape_1.to gives the frame number where the shape disappears.  For shapes that are shown for the "rest of the project"  this will be the last frame number in the project.  

    The variable cpInfoFrameCount  gives the number of frames in the project,  so you can identify shapes that are set to "end of project" by just checking which ones have a "to" variable the same as this cpInfoCount value.     Note that the last slide of the presentation should be blank with a 1 second play time to ensure that there is a distinction between shapes that are shown on the last presentation slide and ones that are set for "rest of project"

    Inspiring
    March 23, 2017

    Great, thank you very much! It work's! I had not known the command cp.D.SmartShape_1.from, that's really helpful!

    Do you also know how to get the coordinates of an arbitrary object in the project (seecp.model.data: Get information of object )? This would be great too!