December 24, 2010

Captivate Swf Events

SWF files generated using Adobe Captivate are capable of firing events when a certain action or event is completed in the SWF file. You can use these events to achieve a tighter integration between Captivate SWFs and, Flash or Flex. 

Captivate SWF events are fired with the Captivate SWF file as the event source so that external observers (like loader swfs in Flash/Flex or Java script) can take some action based upon these events. Widgets can also subscribe to these events.   

The classes related to the events are placed at [InstallationDirectory]/ActionScript/export/as3. They are part of the package com.adobe.captivate.events.This blog introduces different types of Captivate SWF events and provides tips to make use of these events. A demonstration for the same is also included at the end.   

The events could be grouped as: 

  • Movie events
  • Slide events
  • Question submit events
  • Interactive item submit event

 Movie Events:

  1. CPMovieStartEvent — This event is fired when the Captivate movie starts playing.
  2. CPMovieStopEvent — This event is fired after the Captivate movie finishes playing.
  3. CPMovieResumeEvent — This event is fired when the Captivate movie resumes playing.
  4. CPMoviePauseEvent — This event is fired when the Captivate movie is paused.

EventData can be obtained when the movie is paused, or it resumes playing. This includes the frameNumber, slideNumber etc. 

Slide Events :   

  1. CPSlideEnterEvent — This event is fired when any slide in the Captivate movie is entered. 
  2. CPSlideExitEvent — This event is fired when any slide in a Captivate Movie is exited.

EventData can be obtained when the above two slide events are fired. This includes FrameNumber, SlideNumber, SlideLabel, SlideProperties etc.

Question Submit Event: 

             CPQuestionSubmitEvent — This event is fired when a question is submitted and evaluated in a Captivate movie.             

EventData can be obtained when the above event is fired. It includes slideNumber, questionScoringType, questionNumber,questionType, questionAnswered, questionAnsweredCorrectly, questionMaxScore, questionScore, questionMaxAttempts, questionAttempts, InteractionID.  

Interactive Item Submit Event:

             CPInteractiveItemSubmitEvent — This event is fired when an answer for an interactive object (Button, ClickBox, TextEntry Box) is submitted.   

EventData in this case are ItemName, SlideNumber, FrameNumber, includedInQuiz. Corresponding Event data is passed along with the event that is fired.   

Tips to use Captivate SWF events :

  1. External loaders (SWFs), which load a Captivate swf can register for these events upon the loader.content property. To get the fl.containers.UIloader content, use the content property of UILoader component. The eventHandle can be obtained using the eventDispatcher as a property of the movieHandle. Eg : eventHandle = content.eventDispatcher;
  2. Widgets can also listen to these events. Widgets will get an eventDispatcher directly as a property of the movie handle. The widgets can register for the events and be notified when the events occur.

Demonstration:

A simple Flash loader, which loads a Captivate swf and listens for various events, demonstrates some of the Captivate events and data that can be obtained. The Flash loader is a part of the attached ZIP file, which contains:

  • CaptivateSWF.cptx: The source Captivate project.
  • CaptivateSWF.swf: SWF output of the Captivate project.
  • Flash_CpLoader.fla: The source Flash project.
  • Flash_CpLoader.swf: The Flash loader that loads the Captivate swf file.

Download sample source code : Captivate Swf Events Demo-SourceFiles

Open Flash_CpLoader.swf file. You will see:

  • A Captivate movie playing on the right
  • A trace message box on the left that provides information on the Captivate movie events that are obtained.
  • Details about the data that is populated when a Captivate SWF event is obtained. 

Using the playbar of the Captivate swf file, trigger various events. For example, click the play, pause, back, or forward buttons on the playbar. Observe the trace message box and the data populated.

Note: Click the Clear Trace button to clear the trace.

Here is the summary of what you need to do with the Flash loader:

  • Open Flash_CpLoader.swf. This is the main Flash loader swf loading the Captivate swf.
  • In the trace message box , we get the CPMovieStartEvent and CPSlideEnterEvent.
  • The movie event data and slide event data is getting populated in the corresponding text field.
  • Click on the pause button in the playbar of the Captivate swf running at the right bottom.
  • Observe the trace ,CPMoviePauseEvent is fired.
  • Click on play now.CPMovieResumeEvent gets fired.
  • Each time you could check the txtMovie and txtSlide text fields to see the data generated.
  • Click on forward button to jump to slide 2.CPSlideExitEvent is called for Slide 1 first and then CPSlideEnterEvent for Slide 2 is called. 

Additional information is displayed in the txtMovie and txtSlide text fields under the Additional data section.

txtMovie is the dynamic text field which displays the movie event data when any movie event is triggered.

txtSlide is the dynamic text field which displays the slide event data when any slide event is triggered for eg : the slide label , slide number etc.

Youtube link for demo : http://www.youtube.com/watch?v=XHVXdBkveVU

Summary:

The loader in Flash loads the Captivate swf and on Event.COMPLETE , it checks for the eventHandle which is obtained from the SwfLoader.content.eventDispatcher.

Once the eventHandle is obtained , we can listen for the various Captivate events and depending on which event is fired we can get the event data populated or perform any action. This needs to be coded in AS3 in the Flash file.

Right now in the sample file we have demonstrated the movie and slide events and how the event data gets populated when these events are triggered.There will be a couple of more blog posts in the same subject to cover the rest of the events.

Posted by sudeshna9:08 AM
  • Pingback: Tweets that mention Captivate Swf Events « The Adobe Captivate Blog -- Topsy.com

  • Mark

    The .cptx file downloaded does not open in my version of captivate 5 – any thoughts?

    • http://blogs.adobe.com/captivate/ Allen Partridge

      Mark, try to redownload. You might have gotten data corruption on the download. I’ll also check the download to ensure its opening for me. Are you on a PC or a Mac (it shouldn’t matter – just gathering the usual info. )

  • Mark

    Hi Allen
    Thanks for getting back. I have just re-downloaded and I get the same message as I try to open the .cptx.. It warns me about hard disk space (I have plenty), having other projects open (there are none), system resources (other projects open fine) and corrupted downloads (Like I say I have just re-downloaded)
    It’s a mystery!
    I’m on a PC by the way running windows 7
    Thanbks
    Mark

  • Sudeshna

    Hi Mark ,

    You can create any cptx file and publish it. All you need is the Captivate published swf output. This swf will be loaded in the Flash loader component of the fla file. Hence , you could republish the Flash fla file, loading your own captivate swf and then check for the events.
    Steps :
    1. Create any project in Captivate.
    2. Publish the file and name it as “CaptivateSWF.swf” so that you don’t need to change anything in the flash code. Place this swf file in the same folder where the Flash source file(i.e Flash_CpLoader.fla) file is present.
    3. Now open the Flash_CpLoader.fla file and republish it to the same location.
    4. Run the Flash_CpLoader.swf file and check for the events fired.

    Thanks and regards,
    Sudeshna Sarkar

  • Mark

    Thanks Sudeshna
    So there is nothing significant in the original .cptx file – it just has the have the correct name and generate the correctly named .swf
    Thanks a lot – I will give it a try
    ark

  • Praveen

    Hi,

    I tried to load another Captivate SWF on “CPMovieStopEvent” event in same UILoader But it is not loaded and the following error message shown, Can you help, How to load mulitple Captivate SWF one by one?

    TypeError: Error #1010: A term is undefined and has no properties.
    at captivate.veela_as3::rdMovie/slideLoaded()
    at captivate.veela_as3::rdSlide/onSlideLoad()
    at captivate.veela_as3::rdSlide/frame1()

    Thanks,

    C. Praveen

  • Rodrigo

    Please also place the file to download Flash_CpLoader.swc

  • Loading
  • Categories

  • Archives

  • Authors

  • Recent Comments

    • SunTro: After updating to 8.0.1.242 and publishing projects as SCORM 1.2 in html5, I get the error message...
    • Ripken: Can’t get mine to work since I updated my mac to Yosemite. Anyone know if this fixes that?
    • Joshua: I’ve taken this course and it is very informative. My only issue was that Aaron tends to move pretty...
    • Mike: I’m going to buy and learn Snag-IT this ticks me off
    • Tara Keane: I need a TOC that I can click on to jump around content. Any ideas how to do this please?
  • Captivate & eLearning Videos

    Subscribe to Adobe eLearning on YouTube.

    Check out the latest eLearning Videos on AdobeTV

Recently Approved