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
- CPMovieStartEvent — This event is fired when the Captivate movie starts playing.
- CPMovieStopEvent — This event is fired after the Captivate movie finishes playing.
- CPMovieResumeEvent — This event is fired when the Captivate movie resumes playing.
- 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 :
- CPSlideEnterEvent — This event is fired when any slide in the Captivate movie is entered.
- 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 :
- 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;
- 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.
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
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.