Now that Captivate 4 has arrived, there are several new enhancements available to users, like widgets, custom actions and the ability to publish with ActionScript 3 and Flash Player 10.
In this post, I am going to discuss how to import an external SWF into Captivate 4 using AS3 to control the Captivate SWF. Before Captivate 4, everything was done using AS2, so the standard method of using Captivate variables in an external SWF was to go into Flash and input this._parent._parent._parent.rdcmndPause = 1 for example. Once you import the movie into Captivate, the project would be paused once the animation ran.
This worked (and still works with AS2) well if you needed to manipulate Captivate variables externally. But now that Captivate 4 is here, if you want to use AS3, the aforementioned code does not work with AS3, you need to tweak a bit.
Before we continue, you might be thinking "Why on Earth would I need to use external SWFs to interact with Captivate 4?" Well consider this example. What if you are creating an interactive simulation where it is required that the user drag and drop say a folder to the recycle bin on their desktop. There is currently no drag and drop interaction available in Captivate, it needs to be done externally.
So now that you have an understanding of "Why", let's look at how it works.
If you want to pause the Captivate movie with an external SWF, open Flash and do the following:
On frame 1, open the actions panel and input:
var nFrameStart = MovieClip(parent).currentFrame;
var bPauseMovie = 1;
var nPauseAfter = 1;
addEventListener(Event.ENTER_FRAME,function (aevent:Event) {
if( MovieClip(parent).currentFrame - nFrameStart == nPauseAfter ){
if (bPauseMovie) {
MovieClip(parent.parent.parent).rdcmndPause = 1;
}
}
})
//execute code (such as drag and drop) while the Captivate movie is paused.
In short, you must use the ENTER_FRAME event to work with Captivate variables in AS3.
I am still tweaking this where I can and will post updates as soon as I can.
Now that the movie is paused, what happens when you are ready to resume it? What if you want to go to the next slide? Or just resume the movie? Or go to a specific frame in your Captivate movie?
Typically what I like to do is create a function that gets called once I am done executing the code I want. In the drag and drop scenario we've been talking about, Once the 'drop zone' has been met (the user dropped the object they dragged on a certain target), I would then call a function to tell Captivate what I want the Captivate SWF to do. Let's look at how I would tell it to advance to the next slide.
//Call this function to go to the next slide in the Captivate movie.
function goNext(){
addEventListener(Event.ENTER_FRAME,function (aevent:Event) {
if (bPauseMovie) {
MovieClip(parent.parent.parent).rdcmndNextSlide = 1; //Advances to the next slide
MovieClip(parent.parent.parent).rdcmndResume = 1; //Resumes the paused movie
MovieClip(parent.parent.parent).rdcmndGotoFrame = 900 //Takes you to frame 900 of the Captivate movie.
}
bPauseMovie = 0
});
}
In short, this function will check to make sure the Captivate movie is paused, if it is, then it will send the movie to the next slide and set the pause variable to zero. As you can see, you can also call other variables like rdcmndResume or rdcmndGotoFrame, or any other Captivate variable you want to manipulate externally.
In future posts, I will discuss possible issues you may encounter with Captivate 4 as it relates to housing your Captivate SWFs in a wrapper, How to effectively use Advanced Actions and Widgets (I have to get used to them first!)
Stay tuned!
Wednesday, February 18, 2009
Subscribe to:
Posts (Atom)