Cleaning up Adobe Captivate’s SCORM Publishing Template, Part 1: Introduction

Adobe Captivate is an enormously popular tool for e-learning developers. My assumption is that most Captivate users chose Captivate as their development tool because it enables them to publish LMS-compatible courses without requiring any programming skills — no need to know JavaScript, ActionScript, SCORM, etc.

This might explain why no one is up in arms about the astoundingly bad HTML and JavaScript output by Captivate — very few people look under the hood.

In this multi-part series, I will walk through the files Captivate outputs when publishing to SCORM 2004, pointing out the bad parts (hey Adobe: this is constructive criticism, it’s for your own good) and suggesting alternatives when needed. At the end of the series, I will provide a fully-functional SCORM 2004 publishing template you can use with Captivate 5.5.

Getting Started

The first step is to create a very simple Captivate course and publish it using the SCORM 2004 template. This will produce a set of files that we can examine and modify without breaking any templates.

  1. Go to File > New Project > Blank Project
  2. Select a small screen size since we’re just messing around. I selected 640 x 480.
  3. Add something to the stage just so we have something to look at aside from a blank white screen. You can add a text caption, image, etc. — it doesn’t have to be fancy, it just gives us something to look at.
  4. Publish to SCORM 2004
    1. File > Publish Settings
    2. Quiz > Check “Enable reporting for this project”
    3. Under Learning Management System select SCORM.
    4. Click the “Manifest” button. The Manifest dialog will appear; select 2004 from the drop-down menu.
    5. Click OK, then click OK in the Publishing Settings dialog.

Now publish your course: File > Publish. The Publish dialog appears. Nothing to change here, unless you want to select a different location for your files. Click “Publish”.

Attack of the Files

Find the folder containing your published files and take a peek at what Captivate generated for you. It’s quite intimidating, especially with all of those SCORM 2004 XSD files. I suggest sorting the files by kind.

Here’s a quick breakdown of the files:

  • All the DTD and XSD files are a required part of SCORM’s packaging system. The common, extend, unique, and vocab folders all contain SCORM-related XSD files. None of these files or folders should be edited, renamed, moved or deleted. You must keep them, but otherwise it’s best to act as if they don’t exist.
  • The imsmanifest.xml file is required for SCORM 2004. Don’t move or rename it. Some portions of the file may be edited, but you’d better know what you’re doing!
  • The SWF file (in my case sample.swf) is the Captivate course.
  • The HTM file (in my case sample.htm) is the HTML file that contains the SWF.
  • standard.js is a JavaScript file that contains some 3rd-party JavaScript utilities.
  • The SCORM_support folder contains files that Captivate uses to communicate with the LMS when using really old browsers. The files aren’t part of the SCORM standard, they’re just helper files created by Adobe.

Hopefully the files don’t seem so intimidating now that you know what’s what.  Once you ignore the XSD and DTD files, there are actually very few files left to work with.

The next post in this series will cover the HTML file produced by Captivate. Continue to Part 2.

Advertisements

Complete List of Variables for Adobe Captivate 5

While updating my CaptivateController script I noticed there have been some changes to the Captivate variables available to Captivate developers. I figured I should document them for future reference.

Note that some variables available in CP3 and CP4 are no longer available. The following list should be exhaustive for CP5; variables for previous versions of Captivate have been purposely left off this list. I also purposely left off some publicly accessible (but useless) movieclips and objects.

While most people seem to focus on using Captivate variables natively within a Captivate project via the Variables menu or widgets, my focus has been figuring out how accessible/usable they are via JavaScript. Thus you may find small differences between my list and other people’s lists, and differing opinions regarding the usefulness of some variables and publicly accessible movieclips. Regardless, the items below should be accessible via every method: widgets, JavaScript, and the native Variables support in Adobe Captivate.

If you know of any variables that I missed, please leave a comment. Thanks!

Update: Kurt Melander has kindly converted this list to PDF format if you’d like to download or print it. Thanks, Kurt.

Variable Type Description

CPMovieType

[number] Informational variable. Indicates whether the queried SWF is a skin SWF (0) or the main content SWF (1).
CaptivateVersion [string] Informational variable. Indicates the version of Adobe Captivate that published the SWF
DoNotRegisterRightClickBecauseOfAggregator [boolean] Internal variable, no information available
LocalConnectionInUse [boolean] Internal variable, no information available
NoOfTOCEntries [number] Informational variable. Returns the number of items contained in the project’s Table of Contents

PlaybarProperties

[string]
in Chrome

[XML] in Firefox

Internal variable, no information available.

NOTE: This item is
:XML data type in AS3. Because browsers have different support for native XML data types, values returned from this variable should not be considered cross-browser. Use at your own risk.

__loadbase [string]

Informational variable. Returns project’s root file path.

NOTE: This value can only be obtained when the project uses an external skin.

contentHeight [number] Informational variable. Returns the height of the Captivate main SWF (in pixels)
contentLeft [number] Informational variable. Returns the distance of the Captivate main SWF from the leftmost edge of the project (in pixels).
contentSWF [string]

Informational variable. Returns the file name for the project’s main SWF.

NOTE: This value can only be obtained when the project uses an external skin.

contentTop [number] Informational variable. Returns the distance of the Captivate main SWF from the topmost edge of the project (in pixels).
contentWidth [number] Informational variable. Returns the width of the Captivate main SWF (in pixels)
cpAutoPlay [boolean] Informational variable. Indicates whether the project is set to auto-play.
cpCaptivateSkinSWF [boolean]

Informational variable. Indicates whether the SWF is a skin SWF or primary project SWF.

NOTE: This value can only be obtained when the project uses an external skin.

cpCmndCC [number] Command variable. Setting to 1 will enable captioning. Setting to 0 will disable captioning.
cpCmndFastForward [number] Command variable. Setting to 1 will fast-forward the movie (play the movie at a higher framerate). Setting to 0 will return the movie to the normal playback speed.
cpCmndGotoFrameAndResume [number]

Command variable. Will cause the movie to jump to the specified frame and resume playing (frame numbering begins at 0).

Note: frames are not the same as slides.

cpCmndGotoSlide [number]

Command variable. Will cause the movie to jump to the specified slide (slide numbering starts at 0).

Note: frames are not the same as slides.

cpCmndMute [boolean] Command variable. Setting to 1 will disable (mute) the audio. Setting to 0 will restore it to normal.
cpCmndNext [number] Command variable. Setting to 1 will cause the movie to jump to the next slide. Setting to 0 will do nothing.
cpCmndPlaybarMoved [boolean] Command variable. Internal variable. According to Captivate documentation, "Set to 1 if the playbar has moved."
cpCmndShowPlaybar [number] Command variable. Setting to 1 will cause the movie’s playbar to appear. Setting to 0 will make the palybar disappear.
cpCmndVolume [number] Command variable. Setting to a number will cause the volume to change. The volume ranges from 0 (muted) to 100 (maximum volume).
cpContentLoadStart [boolean]

Informational variable. Indicates whether the main project SWF has started.

NOTE: This value can only be obtained when the project uses an external skin.

cpContentLoaded [boolean]

Informational variable. Indicates whether the main project SWF has loaded.

NOTE: This value can only be obtained when the project uses an external skin.

cpContentPositioned Internal variable. No information available.
cpContentScaled Internal variable. No information available.
cpHasSkinSWF [boolean] Informational variable. Indicates whether the Captivate project uses an external skin.
cpInfoAuthor [string] Informational variable. Returns the project author’s name, as entered in the movie’s properties before publishing.
cpInfoCompany [string] Informational variable. Returns the project company’s name, as entered in the movie’s properties before publishing.
cpInfoCopyright [number] Informational variable. Returns the project’s copyright notice, as entered in the movie’s properties before publishing.
cpInfoCourseID [number] Informational variable. Returns the project’s course ID, as entered in the movie’s properties before publishing.
cpInfoCourseName [string] Informational variable. Returns the project’s course name, as entered in the movie’s properties before publishing.
cpInfoCurrentDate [string] Informational variable. Returns the day portion of the current date.
cpInfoCurrentDateString [string] Informational variable. Returns today’s date (US English format).
cpInfoCurrentDay [string] Informational variable. Returns number indicating day of week (1 = Sunday, 2 = Monday, etc.)
cpInfoCurrentHour [string] Informational variable. Returns the current hour (24 hour clock format).
cpInfoCurrentMinutes [string] Informational variable. Returns the minutes portion of the current time.
cpInfoCurrentMonth [string] Informational variable. Returns the month portion of the current date.
cpInfoCurrentSlide [number] Informational variable. Returns the current slide number. (Uses 1-based index)
cpInfoCurrentSlideLabel [string] Informational variable. Returns the slide label for the current slide, if available.
cpInfoCurrentSlideType [string] Informational variable. Returns the slide type for the current slide.
cpInfoCurrentTime [string] Informational variable. Returns the current time, including seconds (24 hour clock format).
cpInfoCurrentYear [string] Informational variable. Returns the year portion of the current date.
cpInfoDescription [string] Informational variable. Returns the project’s description, as entered in the movie’s properties before publishing.
cpInfoElapsedTimeMS [number] Informational variable. Returns the amount of time (in milliseconds) that has elapsed since the project began playing.
cpInfoEmail [string] Informational variable. Returns the project author’s e-mail address, as entered in the movie’s properties before publishing.
cpInfoEpochMS [number] Informational variable. Returns the current time elapsed (in milliseconds) since January 01, 1970.
cpInfoHasPlaybar [number] Informational variable. Indcates whether the Captivate movie has a playbar. 1=true, 0=false
cpInfoIsStandalone [number] Informational variable. Indicates whether Captivate project is en .exe or .app file (1) or standard SWF (0).
cpInfoLastVisitedSlide [number] Informational variable. Returns the last visited slide number. (Unlike cpInfoCurrentSlide, this variable uses 0-based index)
cpInfoPercentage [number] Informational variable. Returns the current score as a percentage (if available).
cpInfoPrevSlide [number] Informational variable. Returns the number of the slide before the current slide. (Uses 1-based index)
cpInfoProjectName [string] Informational variable. Returns the project’s name, as entered in the movie’s properties before publishing.
cpInfoWebsite [string] Informational variable. Returns the project’s web addess, as entered in the movie’s properties before publishing.
cpLockTOC [number] Command variable. Setting to 1 disables user interaction on the Table of Contents. Setting to 0 re-enables (unlocks) user interaction.
cpMovieHeight [number] Informational variable. Returns the height of the Captivate project, in pixels.
cpMovieWidth [number] Informational variable. Returns the width of the Captivate project, in pixels.
cpMovieXForEmbededPlaybar [number] Informational variable. Returns the x coordinate (left position) of the Captivate project’s toolbar, if available.
cpMovieXForTOC [number] Informational variable. Returns the x coordinate (left position) of the Captivate project’s Table of Contents movieclip, if available.
cpMovieYForEmbededPlaybar [number] Informational variable. Returns the y coordinate (top position) of the Captivate project’s toolbar, if available.
cpMovieYForTOC [number] Informational variable. Returns the y coordinate (top position) of the Captivate project’s Table of Contents movieclip, if available.
cpOrgSWFPath [string]

Informational variable. Provides the file name for the project’s main SWF. Appears to duplicate functionality of cpOrgSWFPath.

NOTE: This value can only be obtained when the project uses an external skin.

cpQuizInfoAnswerChoice [string] Informational variable. Returns the chosen answer for the quiz question.
cpQuizInfoAttempts [number] Informational variable. Returns the number of times the quiz has been attempted.
cpQuizInfoLastSlidePointScored [number] Informational variable. Returns the score for the last visited quiz slide.
cpQuizInfoMaxAttemptsOnCurrentQuestion [number] Informational variable. Returns the number of attempts allowed for this quiz question.
cpQuizInfoNoQuestionsPerQuiz Informational variable. No information available. Best guess: returns the number of questions in the quiz.
cpQuizInfoPassFail [number] Informational variable. Returns the result of the quiz: pass or fail.
cpQuizInfoPointsPerQuestionSlide [number] Informational variable. Returns the number of points for this quiz question.
cpQuizInfoPointsscored [number] Informational variable. Returns the total number of points scored in the project.
cpQuizInfoQuestionSlideTiming [number] Informational variable. Returns the time limit for the current question (in seconds).
cpQuizInfoQuestionSlideType [string] Informational variable. Returns the current question’s type (multiple-choice, true-false, likert, etc.).
cpQuizInfoQuizPassPercent [number] Informational variable. Returns the passing percentage for the quiz.
cpQuizInfoQuizPassPoints [number] Informational variable. Returns the passing points for the quiz.
cpQuizInfoTotalCorrectAnswers [number] Informational variable. Returns the number of correctly answered quiz questions.
cpQuizInfoTotalProjectPoints [number] Informational variable. Returns the total number of points for the project.
cpQuizInfoTotalQuestionsPerProject [number] Informational variable. Returns the total number of questions for the project.
cpQuizInfoTotalQuizPoints [number] Informational variable. Returns the total number of quiz points for the project.
cpQuizInfoTotalUnansweredQuestions [number] Informational variable. Returns the total number of unanswered questions for the project.
endSwfAction [number] Internal variable. No information available.
expired [boolean] Internal variable. No information available. Best guess: Boolean indicating whether time limit has elapsed.
hasProjectFadeOut [boolean] Internal variable. No information available. Best guess: Boolean indicating whether last slide in project is set to fade out.
inAutoPlayState [boolean] Internal variable. No information available. Best guess: Boolean indicating whether project is set to auto-play.
isCPMovie [boolean] Informational variable. Indicates whether the SWF is a Captivate SWF.
isContiniousModeRecording [number] Internal variable. No information available. (Yes, that’s how it was spelled in the code.)
isCustomizable [boolean]

Internal variable. No information available. Best guess: Indicates whether the skin is customizable.

NOTE: This value can only be obtained when the project uses an external skin.

isForceMuteAudio [boolean] Internal variable. No information available. Best guess: Indicates whether the audio was muted by the user.
isPlayBarBtnClicked [boolean] Internal variable. No information available. Best guess: Indicates whether a specific action was performed via clicking the playbar (such as muting audio).
isPreview [number] Internal variable. No information available. Best guess: Indicates whether the SWF is a preview SWF (used when previewing projects within the Captivate authoring environment).
isPreviewForAudioDialog [boolean] Internal variable. No information available. Best guess: Indicates whether the SWF is a preview SWF (used when previewing projects within the Captivate authoring environment).
isPreviewSkin [boolean] Internal variable. No information available. Best guess: Indicates whether the project SWF’s skin is a preview SWF (used when previewing projects within the Captivate authoring environment).
lmsString [string] Internal variable. No information available. Best guess: The text displayed when Captivate initializes an LMS connection (SCORM, AICC, etc.).
loadedFromAggregator [boolean] Internal variable. No information available. Best guess: Indicates whether the Captivate SWF was loaded as part of an aggregator project.
m_quizPoolColl [object] Internal variable. No information available. Best guess: Object containing question pool questions.
movieQuality [string] Internal variable. No information available. Best guess: Indicates quality setting of SWF playback.

movieXML

[string] in Chrome

[XML] in Firefox

Internal variable, no information available.

NOTE: This item is
:XML data type in AS3. Because browsers have different support for native XML data types, values returned from this variable should not be considered cross-browser. Use at your own risk.

needToMuteAudioForAggregator [boolean]

Internal variable. No information available.

NOTE: This value can only be obtained when the project uses an external skin.

passwordPresent [boolean] Internal variable. Indicates whether a password has been supplied.
pbcBtnTips [object] Internal variable. Alias for pbcBtnTips_ENU.
pbcBtnTips_ENU [object] Internal variable (array). Returns list of tooltips used by the playbar buttons.
playbarBarAlign [number]

Internal variable. No information available.

NOTE: This value can only be obtained when the project uses an external skin.

playbarHeight [number] Informational variable. Returns height of playbar, in pixels.
playbarPosition [number]

Internal variable. No information available.

NOTE: This value can only be obtained when the project uses an external skin.

rdIsInLivePreviewMode [boolean] Internal variable. No information available. Best guess: Indicates whether the SWF is a preview SWF (used when previewing projects within the Captivate authoring environment).
rdIsPreview [boolean] Internal variable. No information available. Best guess: Deprecated variable replaced by isPreview
rdIsPreviewInBrowser [boolean] Internal variable. No information available.
rdIsStandalone [boolean] Internal variable. No information available. Best guess: Deprecated variable replaced by cpInfoIsStandalone
rdcmndCC [number] Command variable (deprecated). Alias for cpCmndCC.
rdcmndExit [number] Command variable. According to Captivate documentation, "Exit the movie. Set to 1 to exit." Has never worked for me.
rdcmndGotoFrame [number] Command variable (deprecated). Alias for cpCmndGotoFrame.
rdcmndGotoFrameAndResume [number] Command variable (deprecated). Alias for cpCmndGotoFrameAndResume.
rdcmndGotoSlide [number] Command variable (deprecated). Alias for cpCmndGotoSlide.
rdcmndMute [boolean] Command variable (deprecated). Alias for cpCmndMute.
rdcmndNext [boolean] Command variable (deprecated). Alias for cpCmndNext.
rdcmndNextSlide [number] Command variable (deprecated). Alias for cpCmndNext.
rdcmndPause [number] Command variable. Setting to 1 will cause the movie to stop playing (pause). Setting to 0 will do nothing.
rdcmndPlaybarMoved [boolean] Command variable (deprecated). Alias for cpCmndPlaybarMoved.
rdcmndPrevious [number] Command variable. Setting to 1 will cause the movie to stop playing (pause). Setting to 0 will do nothing.
rdcmndResume [number] Command variable. Setting to 1 will cause the movie to go backwards to the previous slide. Setting to 0 will do nothing.
rdinfoCurrentFrame [number] Informational variable. Returns current frame number using 0-based index.
rdinfoCurrentSlide [number] Informational variable (deprecated). Alias for cpInfoCurrentSlide.
rdinfoCurrentSlideInProject [number] Informational variable. No information available. Best guess: Alias for cpInfoCurrentSlide.
rdinfoFPS [number] Informational variable. Returns the SWF’s frame rate (in seconds).
rdinfoFrameCount [number] Informational variable. Returns the number of frames in the SWF.
rdinfoHasPlaybar [boolean] Informational variable (deprecated). Alias for cpInfoHasPlaybar.
rdinfoSlideCount [number] Informational variable. Returns the number of slides in the Captivate movie.
rdinfoSlidesInProject [number] Informational variable. No information available. Best guess: An unused/deprecated variable.
rdinfocurrFrame [number] Informational variable. No information available. Best guess: Alias for rdinfoCurrentFrame.
skinHeight [number]

Internal variable. No information available.

NOTE: This value can only be obtained when the project uses an external skin.

skinWidth [number]

Internal variable. No information available.

NOTE: This value can only be obtained when the project uses an external skin.

swfCmtAutoPlay [boolean] Internal variable. No information available. Best guess: Indicates whether the SWF will auto-play when in commenting mode.
swfCommenting [boolean] Internal variable. No information available. Best guess: Indicates whether the SWF is in commenting mode.
tocInitDone [boolean] Internal variable. Indicates when the Table of Contents has finished initializing.
waitCount [number] Internal variable. Indicates how long the SWF has been waiting (used for internal timer-related functions).

CaptivateController Updated to Support Adobe Captivate 5

By popular demand, I’ve updated my CaptivateController to work with Adobe Captivate 5 (CP5). Since this is an open-source project, there’s no upgrade fee. (What? “Adobe” and “no upgrade fee” in the same paragraph?!) I kid, I kid… I’m a kidder.

As you may have heard, Adobe Captivate 5 is a complete re-write of the Adobe Captivate application. As such, there are a few significant changes under-the-hood. For example, Adobe Captivate 5 does not support ActionScript 2, and will only publish to ActionScript 3. The Captivate developers eliminated a few of the old system variables while adding a few new ones. Showing and hiding the playbar now works very reliably (yay!). Most notably, the developers added extra ExternalInterface support via the cpEIGetValue and cpEISetValue callback functions while eliminating the cpSetValue callback, which explains why the previous version of the CaptivateController didn’t work with CP5 SWFs.

As for the updated CaptivateController, it works the same as the previous version. Most of the changes were under-the-hood, so you shouldn’t need to edit any of your code, and should be able to drop this new version on top of your old one. No system restart required!

If you encounter any bugs, please let me know by posting in the comments. I’d also be happy to hear any success stories you may have.

Adobe Captivate: What the heck is g_intAPIType?

If you spend any time using Adobe Captivate to create SCORM-conformant courses, you’re bound to have run into an issue or two that caused you to read some Captivate forum posts. Almost without fail, someone will mention that the solution to their problem was changing the value of the magical g_intAPIType JavaScript variable from 1 to 0 or from 0 to 1.

So what the heck is g_intAPIType, and why does changing it make a difference?

The short version is this: Captivate courses, when published for SCORM, typically use one of two communication methods: FSCommand or getURL. FSCommand works really well in some browsers, such as Internet Explorer, but has spotty support in others. getURL works in all browsers, but uses a more complicated communication system when sending data to your Captivate file from the LMS. It also makes a lot of clicking sounds.

Setting g_intAPIType to 0 means you’re forcing Captivate to use FSCommand in all browsers. Setting g_intAPIType to 1 means you’re forcing Captivate to use getURL in all browsers. If you don’t manually specify the value of g_intAPIType, Captivate’s SCORM template includes some browser sniffing that automatically sets g_intAPIType to 0 for Internet Explorer and 1 for all other browsers.

Want to know more about FSCommand versus getURL? Colin Moock wrote a good FSCommand tutorial that covers the basics.

Note: ExternalInterface has replaced both of these methods as the favored Flash-to-JavaScript communication method, but Captivate has not caught up yet.

Customizing SCORM Manifests in Captivate and Articulate Presenter

Someone recently asked me if it was possible to customize Captivate’s SCORM manifest to reduce the need for manual editing after publishing. In her case, the manifest needed to be edited to include SumTotal TotalLMS’s custom SCORM extensions.  The answer is yes. Here’s how.

Find the Captivate files

Captivate’s publishing files are located at:

C:\Program Files\Adobe\Adobe Captivate 4\Templates\Publish

Make your edits

Find the manifest files (manifest.xml for SCORM 1.2 and manifest2004.xml for SCORM 2004), then make your edits.

If you’re adding custom SCORM extensions such as SumTotal’s c2l_cp extensions, don’t forget to include the supporting XSD files. If you’re using SCORM 2004 you can drop the extra XSD file(s) into the “Manifest2004” folder. If you’re publishing to SCORM 1.2, you’ll need to manually add the custom XSD file to your published files.

Rinse, repeat

You’ll need to repeat the process for every computer in your office that has Captivate installed. Otherwise someone on a different computer may inadvertently publish the Captivate project using the factory publishing templates.

What about Articulate?

You can do the same thing with Articulate Presenter. Their publishing templates are located here:

C:\Program Files\Articulate\Presenter\players\

CaptivateController updated

Bug fixes!

The CaptivateController has been updated to fix the gotoSlideAndPlay and gotoSlideAndStop bugs.

Also, gotoSlideAndPlay and gotoSlideAndStop have been edited to use standard numbering in place of zero-based numbering. This means when you want to jump to slide 4, you use mycontroller.gotoSlideAndPlay(4) instead of mycontroller.gotoSlideAndPlay(3).

I had a number of requests for adding a ‘toggle table of contents’ method, but unfortunately it won’t be added at this time. It turns out that while you can toggle the TOC using the controller, it breaks the Captivate movie’s playbar — the playbar loses awareness of whether the TOC is visible or not. This is therefore not a feature I’m prepared to add. You can still toggle the TOC yourself using KCWebPlaza’s workaround (listed in the comments).

I will continue to monitor the TOC possibilities and would be happy to hear suggestions.

View the original post, download links and (somewhat spartan) documentation here.

Thanks to everyone who contacted me about the bugs.

Introducing the CaptivateController

This post has been updated to reflect changes to the CaptivateController since its initial release

It took me much much longer than I anticipated, but I am happy to announce the new CaptivateController utility. The CaptivateController is a JavaScript utility that helps you control Captivate SWFs as well as get/set Captivate variable values using simple JavaScript commands. For example:

//Assuming your SWF is embedded using the ID "Captivate"
var myMovie = CaptivateController("Captivate");
myMovie.pause(); //Pauses the Captivate SWF
var author_name = myMovie.get("cpInfoAuthor"); //Queries variables
myMovie.set("myCustomeCaptivateVariable", "myValue"); //Sets variable values

For those of you familiar with the pipwerks.captivate.control utility, this CaptivateController is not a simple rehash of the original; it is a complete re-write that adds a number of extra features, including:

  • Support for Captivate 2, Captivate 3, Captivate 4, and Captivate 5.x files
  • Auto-detection for skins; you can write the exact same JavaScript whether your SWF uses a skin or not
  • New query methods, including the ability to query a user-defined variable in a Captivate 4+ file
  • New set method for setting the value of a variable in Captivate 4+

The CaptivateController is intended to make your life easier — it deals with a number of inconsistencies so you don’t have to, including inconsistencies between Captivate 2/3 SWFs and Captivate 4 SWFs (there was a major shift under the hood, going from using GetVariable to using Captivate 4’s proprietary cpGetValue via ExternalInterface). It also handles inconsistencies with Flash Player in different browsers. Safari and Internet Explorer each provided their own small challenges.

There are still some inconsistencies that cannot be solved using JavaScript; for instance, Captivate 4 SWFs published using ActionScript 3 provide a richer set of system variables than Captivate 4 files published using ActionScript 2. I expected to have the same access to all system variables regardless of ActionScript version, but alas it was not meant to be. Captivate 5+ provides many m ore system variables than previous versions of Captivate.

Can check out the Automated Test Suite, which illustrates which variables are available for each flavor of Captivate SWF (has not been updated for Captivate 5+).

Download

The CaptivateController weighs in at about 6kb (compressed) and has been successfully tested in Chrome (Mac/Windows), Firefox (Mac/Windows), Safari (Mac), and Internet Explorer (Windows).

Quickie documentation

I haven’t had the time to do a full write-up of the CaptivateController API, but the following information should be enough to get you started.

Don’t forget to check out the test suite. A list of Captivate Variables can be found on the Automated Test Suite, a list of Captivate 2-4 variables can be found here, and new CP5+ variables can be found here.

“Control” methods available in the API

Method Notes
pause()
resume()
next()
previous()
rewindAndStop()
rewindAndPlay()
gotoSlideAndPlay(slidenumber) Uses 1-based numbering: gotoSlideAndPlay(3) will take you to Slide 3. If you prefer Captivate’s built in zero-based numbering, use useZeroIndex(true) to change the numbering to a zero-based index.
gotoSlideAndStop(slidenumber) Uses 1-based numbering: gotoSlideAndStop(3) will take you to Slide 3. If you prefer Captivate’s built in zero-based numbering, use useZeroIndex(true) to change the numbering to a zero-based index.
gotoFrameAndPlay(framenumber)
gotoFrameAndStop(framenumber)
volume(volumelevel)
  • Takes number, 0-100
  • Returns current volume level, 0-100
  • Volume only works in CP4+
mute()
unmute()
muteAndShowCaptions()
unmuteAndHideCaptions()
showCaptions()
hideCaptions()
showInfoBox()
hidePlaybar() Doesn’t seem to work consistently via JavaScript
showPlaybar() Doesn’t seem to work consistently via JavaScript
lockTOC()
  • Enables/disables user interaction on TOC
  • Only works in CP4+
unlockTOC()
  • Enables/disables user interaction on TOC
  • Only works in CP4+
exit()
useZeroIndex(boolean) Specifies whether gotoSlideAndPlay and gotoSlideAndStop should use zero-based numbering (0 = slide 1). Set to true to use zero-based numbering. The default is false. Warning: This should only be invoked if you wish to use a zero-based index for gotoSlideAndPlay and gotoSlideAndStop.

Example:

//Assuming your SWF is embedded using the ID "Captivate"
var myMovie = CaptivateController("Captivate");
myMovie.pause(); //Pauses the Captivate SWF
myMovie.mute(); //Mutes the Captivate SWF

Commands can also be chained together, like so:

var myMovie = CaptivateController("Captivate");
myMovie.pause().mute(); //Pauses then mutes Captivate SWF

Query methods

The primary query technique is to use .query(“captivate_variable_name”). For example,

var myMovie = CaptivateController("Captivate");
//Retrieves the author's name, if available
var author = myMovie.query("cpInfoAuthor");

You can also use this method to query user-defined variables:

var myMovie = CaptivateController("Captivate");

//Retrieves the variable My_custom_variable_name, if available
var myUserDefinedvariable = myMovie.query("My_custom_variable_name");

I have created some additional query methods below. Some are designed to help avoid worrying which version of Captivate is being used (ie they work with both CP3 and CP4), and others provide data directly from the Flash SWF (not using CP variables).

Method Notes
captivateVersion() Returns major number, currently either 2 or 4 (Captivate 3 SWFs self-identify as CP2 SWFs, nothing can be done about this.)
asVersion() Returns either 2 or 3
FPS() Returns the frames per second of the SWF
hasSkinSWF() Returns a boolean indicating whether the SWF is using a skin
hasTOC() Returns a boolean indicating whether the movie has a Table of Contents
hasPlaybar() Returns a boolean indicating whether the SWF has a playbar
width() Returns a number indicating width in pixels
height() Returns a number indicating height in pixels
volume() Returns a number (0-100) indicating volume level. Note: volume only works in CP4+
percentLoaded() Standard Flash SWF method, not specific to Captivate.
getname() Returns the SWF’s ID. Standard Flash SWF method, not specific to Captivate.
geturl() Returns the SWF’s URL. Standard Flash SWF method, not specific to Captivate.

You can also grab a reference to the SWF itself by using .swf. This is the equivalent of document.getElementById():

var myMovie = CaptivateController("Captivate");
myMovie.swf === document.getElementById("Captivate");

Set method

There is a new set method (added November 2011) that enables developers to easily set the value of a Captivate variable using JavaScript. For example:


var myMovie = CaptivateController("Captivate");
myMovie.set("myCustomCaptivateVariable", "myValue");

Here is a test page demonstrating the set method.

Download

Download the CaptivateController The CaptivateController is now hosted on GitHub! The CaptivateController is licensed under an MIT license, and is free to use.

DISCLAIMER: This controller is provided as-is. Use this controller at your own risk. I cannot be held responsible for any problems you may encounter while using the controller. kthxbai.

Captivate 4 variables gone wild

Update (August 2010): I have published a new list of Captivate variables that are specific to Adobe Captivate 5. Check it out.

The folks at Adobe recently published a list of Captivate 4 variables. While it’s a solid list, it’s not really a complete list.

Here is a list of variables I dug up while combing through Captivate 4’s source AS files. I tried to add descriptions where I could, and will continue to revise this list as I get more information. Kudos to Michael at www.cpguru.com for posting his helpful list, too.

Notes:

  • I’ve tested each of these variables in JavaScript to ensure they exist and are accessible, and have weeded out variables that return errors.
  • I’ve also included Captivate 3 variables at the bottom of this page.

Update: Kurt Melander was kind enough to clean up this list and convert it to PDF format for those who’d like to print it out. Download PDF version.

Captivate 4 Variables

Functional variables (perform an action)

Variable Returns Default values Description (if available)
cpAutoPlay boolean true Toggles auto-play on (true) or off (false). Movie auto-plays by default.
cpCmndCC number 0 Toggles closed captioning on (1) or off (0). Replaces rdcmndCC.
cpCmndFastForward number 0 Setting to 1 increases speed of playback.
cpCmndGotoFrameAndResume number -1 Jumps to the specified frame number (NOT slide number) and resumes playback.

Replaces rdcmndGotoFrameAndResume.

cpCmndMute boolean false Toggles audio. Setting to true mutes the audio, setting to false unmutes the audio.

Replaces rdcmndMute.

cpCmndNext number 0 Setting value to 1 will jump to the next slide in project.

Replaces rdcmndNext

cpCmndShowPlaybar number 1 Toggles playbar visibility. Setting to 0 will hide the playbar, setting to 1 will restore it.

Replaces rdcmndHidePlaybar.

cpCmndVolume number 100 Sets audio volume (if applicable). Range is 0-100, where 0 is off and 100 is full volume. Querying cpCmndVolume will return the current volume level.
rdcmndGotoSlide number -1 Jumps to the specified slide number. Takes slide number (0-based index) as argument.
rdcmndPlaybarMoved boolean false

Informational variables (retrieve or set data)

Variable Returns Sample values Description (if available)
CaptivateVersion string 4.0.0 Returns version of Captivate that published the SWF.
cpCmndPlaybarMoved boolean false Replaces rdcmndPlaybarMoved.
cpHasSkinSWF boolean false Returns boolean indicating whether the movie is using a SWF-based skin.
cpInfoAuthor string Philip Hutchison Returns the project author’s name, if available.
cpInfoCompany string pipwerks Returns the project company’s name, if available.
cpInfoCopyright number 2009 Returns the project’s copyright notice, if available.
cpInfoCurrentDate string 11 Returns the day of the month using the client’s system clock.

String(now.getDate())

cpInfoCurrentDateString string 5/11/2009 Returns the calendar date in mm/dd/yyyy format using the client’s system clock.

Returns (now.getMonth() + 1 + “/” + now.getDate() + “/” + now.getFullYear());

cpInfoCurrentDay string 2 Returns the numerical day of the week using the client’s system clock (Sunday is day 1).

Returns String(now.getDay()+ 1);

cpInfoCurrentHour string 19 Returns the current hour using the client’s system clock.

Returns String(now.getHours());

cpInfoCurrentMinutes string 59 Returns the current minute using the client’s system clock.

Returns String(now.getMinutes());

cpInfoCurrentMonth string 5 Returns the numerical month using the client’s system clock (January is 1).

Returns String(now.getMonth() + 1);

cpInfoCurrentSlide number 1 Returns the current slide number. Unlike rdinfoCurrentSlide, cpInfoCurrentSlide uses 1-based indexing, so slide 1 of the project will return 1.

Returns (rdinfoCurrentSlide + 1);

cpInfoCurrentSlideLabel string SlideLabel:0 Returns the label of the slide, if available.
cpInfoCurrentSlideType string NormalSlide Returns a string indicating the current slide’s type. There are currently three possible results: “NormalSlide”, “QuestionSlide”, and “RandomQuestionSlide”
cpInfoCurrentTime string 19:59:27 Returns the current time in HH:MM:SS format using the client’s system clock. Note: uses 24-hour clock.

Returns (now.getHours() + “:” + now.getMinutes() + “:” + now.getSeconds());

cpInfoCurrentYear string 2009 Returns the current year in YYYY format using the client’s system clock.

Returns String(now.getFullYear());

cpInfoDescription string This demonstration will teach you the… Returns the project description, if available.
cpInfoElapsedTimeMS number 1537 Returns the amount of time (in milliseconds) that has elapsed since the movie began playing.

Returns (cpInfoEpochMS – movie.m_StartTime)

cpInfoEmail string hello@world.org Returns the project author’s email address, if available.
cpInfoEpochMS number 1242097167686 Per Adobe [link no longer available]: “returns the number of milliseconds since midnight January 1, 1970, universal time, for the specified Date object. Use this method to represent a specific instant in time when comparing two or more Date objects.”

Returns now.getTime();

cpInfoHasPlaybar number 1 Returns a boolean (in number format) indicating whether the Captivate file was published with playback controls (a playbar).
cpInfoIsStandalone number 0
cpInfoLastVisitedSlide number 0 Returns the index number of the last visited slide. Uses zero-based numbering (0 = slide 1, 1 = slide 2).
cpInfoPercentage number 0
cpInfoPrevSlide number -1 Returns the index number of the slide that comes before the current slide. Uses zero-based numbering (0 = slide 1, 1 = slide 2).
cpInfoProjectName string CaptivateController Returns the project name, if available.
cpInfoWebsite string www.pipwerks.com Returns the website listed in the project properties, if available.
cpMovieHeight number 432 Returns the movie’s original height, regardless of how it has been sized via HTML or CSS.
CPMovieType number 1
cpMovieWidth number 551 Returns the movie’s original width, regardless of how it has been sized via HTML or CSS.
cpQuizInfoAnswerChoice string
cpQuizInfoAttempts number 1
cpQuizInfoLastSlidePointScored number 0
cpQuizInfoMaxAttemptsOnCurrentQuestion number 0
cpQuizInfoNoQuestionsPerQuiz number 0
cpQuizInfoPointsPerQuestionSlide number 0
cpQuizInfoPointsscored number 0
cpQuizInfoQuestionSlideTiming number 0
cpQuizInfoQuestionSlideType string choice
cpQuizInfoQuizPassPercent number 0
cpQuizInfoQuizPassPoints number 0
cpQuizInfoTotalCorrectAnswers number 0
cpQuizInfoTotalProjectPoints number 0
cpQuizInfoTotalQuestionsPerProject number 0
cpQuizInfoTotalQuizPoints number 0
cpQuizInfoTotalUnansweredQuestions number 0
inAutoPlayState boolean false
isCPMovie boolean true Returns a boolean indicating whether this movie was published using Adobe Captivate.
isPreview number 0 Returns a boolean (in number format) indicating whether this is a preview. Primarily used internally by Captivate when previewing a project. Replaces rdIsPreview.
isPreviewSkin number 0 Returns a boolean (in number format) indicating whether this is a skin for a preview. Primarily used internally by Captivate when previewing a project.
loadedFromAggregator boolean false Returns a boolean indicating whether the SWF has been loaded by Captivate’s aggregator.
LocalConnectionInUse boolean false Returns a boolean indicating whether the movie is using LocalConnection. This is primarily used internally by Captivate.
NoOfTOCEntries number -1 Returns a count of entries in the Table of Contents, if available.
pbcBtnTips object [array] Rewind, Back, Play,
Pause, Forward,
Closed Captioning,
Audio On, Audio Off,
Exit, Information,
Dummy for slider,
Table Of Contents,
2x Fast Forward Speed,
4x Fast Forward Speed,
Normal Speed, Print
Returns the label values used in the playback controller’s tool tips.
playbarHeight number 31 Returns the height of the playbar in pixels, if applicable.
playbarPosition number 3 Returns the position of the playbar in pixels, if applicable.
rdIsPreview boolean false Deprecated. Replaced by isPreview.
rdinfoCurrentFrame number 41 Returns the number of the current frame (NOT slide), counting from the beginning of the movie’s timeline.
rdinfoCurrentSlide number 0 Deprecated. Replaced by cpInfoCurrentSlide.
rdinfoCurrentSlideInProject number 0
rdinfoFPS number 30 Returns the SWF’s frames per second rate.
rdinfoFrameCount number 90 Returns the number of frames in the entire SWF.
rdinfoSlideCount number 1
rdinfoSlidesInProject number 1 Returns the number of slides in the project.
rdinfocurrFrame number 2
swfCmtAutoPlay boolean false Returns boolean indicating whether SWF commenting auto-play is enabled. This is only used by the SWF Commenting AIR application.
swfCommenting boolean false Returns boolean indicating whether SWF commenting auto-play is enabled. This is only used by the SWF Commenting AIR application.
tocInitDone boolean true Returns boolean indicating whether the Table of Contents has finished initializing.

Captivate 3 Variables

Functional variables (perform an action)

Variable Returns Default values Description (if available)
rdcmndCC string 0 Toggles closed captioning on (1) or off (0).
rdcmndGotoSlide string -1 Jumps to the specified slide number. Takes slide number (0-based index) as argument.
rdcmndMute string 0 Toggles audio. Setting to 1 mutes the audio, setting to 0 unmutes the audio.
rdcmndNext string 0 Setting value to 1 will jump to the next slide in project.
rdcmndHidePlaybar string 0 Toggles playbar’s visibility

Informational variables (retrieve or set data)

Variable Returns Sample values Description (if available)
CaptivateVersion string 2.0.0 Returns version of Captivate that published the SWF.
rdIsPreview string 0 Returns a boolean (in number format) indicating whether this is a preview. Primarily used internally by Captivate when previewing a project.
rdinfoCurrentFrame string 1 Returns the number of the current frame (NOT slide), counting from the beginning of the movie’s timeline.
rdinfoCurrentSlide string 1 Returns the current slide number using zero-based indexing (slide 1 of the project will return 0).
rdinfoCurrentSlideInProject string 1
rdinfoFPS string 24 Returns the SWF’s frames per second rate.
rdinfoFrameCount string 2889 Returns the number of frames in the entire SWF.
rdinfoHasPlaybar string 1 Returns a boolean (in number format) indicating whether the Captivate file was published with playback controls (a playbar).
rdinfoSlideCount string 13
rdinfoSlidesInProject string 13 Returns the number of slides in the project.
rdinfocurrFrame string 0
rdcmndPlaybarMoved string 0