When Captivate 5 came out, one of the interesting feature that was added to the widget API was the EventDispatcher and the different movie events. Before this feature, the developer had to hook himself on the ENTER_FRAME event and check, on each frame, the value of different captivate variables in order to determine the current slide, the current frame or the movie status. This seemed to be a very promising feature long awaited by widget developers.
Unfortunately, tapping into it is not as simple as it seems. First hurdle: the Captivate Helpdoesn’t mention this EventDispatcher at all. However, sometimes if you dig and are patient enough, you can find gems … and the Captivate 5 installation folder has a few nice ones. Hidden in the ActionScript folders are the different classes that can be accessed by the widget at runtime. If you are familiar with the lifecycle of a widget, you know that at runtime, a movie handle is passed to the widget via the cpSetValue() function. For those of you that aren’t, consider reading this.
So, at runtime, the Captivate player passes the movie handle to the widget. From there, you can call the getMovieProps() function to retrieve a reference to the CPMovieProperties instance. This class instance contains a property that is not mentioned in the help and that is named: eventDispatcher. This property will return an instance of an IEventDispatcher which will allow you to monitor the following Captivate events:
- CPSlideEnterEvent (Entering a slide)
- CPSlideExitEvent (Exiting a slide)
- CPMovieStartEvent (Starting the movie)
- CPMovieStopEvent(Stoping the movie)
- CPMoviePauseEvent (Pausing the movie)
- CPMovieResumeEvent (Resuming the movie)
You would think that the problems stop here and that the widget can now live happily ever after. Hum … sorry to disappoint you but the eventing system is a bit flaky. Here are my observations:
- The first time the EnterSlide event is fired on the first slide, the movie is on frame #2. If you rewind the movie, the EnterSlide event is now fired on frame #3. So, why frame #2 initially and frame #3 ever after?
- There is a lost frame between the ExitSlide event and the next EnterSlide event. For example, Side 2 fires up an ExitEvent on say frame 181. The movie keeps playing and the next EnterSlide event is firex on frame … #183. What happened to frame #182? Granted it’s not that important but it’s bizarre none the less.
- When the movie stops on the last slide (say 4) and on the last frame (say 285), if the movie is rewound, an ExitSlide event is thrown originating from Slide 4 (fine) but for frame … #1! That is impossible, you expect it to be Slide 4 – Frame 285. Looks like a bug to me.
- There is a very strange behavior when dragging the thumb of the progress bar in the playbar. If you start the movie and pause it after a few seconds but before the first slide ends, you can scrub the thumb back and forth without any problem. That is as long as you scrub within the first slide. If the thumb crosses over to slide #2, an ExitEvent for slide 1 and an EnterEvent for slide 2 are thrown. That is perfectly normal. What is not is when you scrub back the thumb into slide 1, then you get an EnterSlide event for each frame of slide #1. This is very annoying! If you want to check that up for yourselft, just let the movie play to the end and then click on the thumb and scrub back. If your movie has 200 frames, you’ll get 200 EnterEvents. Again sounds like a bug to me!
- When you click on the thumb of the progress bar you get inconsistent events such as pausing, resuming, exiting a slide, etc. I was not able to get a reproducable pattern. However, one thing I can reproduce is if I scrub the thumb all the way back to the beginning of the movie, I then always get a Resume event followed by an Enter event.
This inconsistent behavior makes this feature hard to use in real life without resorting to hacks. If you plan to use Captivate Events, just be on the look out for unwanted side effects. Now, I will need to report these problems to the Captivate team … unless one of the Captivate developer happens to read this blog