One of the features I like to tote about WidgetFactory 5 is that it’s compatible with both Captivate 5 AND Captivate 4. That means a single widget file can be imported into both versions of Captivate and still work. However, what if you built a widget that used the new Captivate 5 events? What if you built a widget that had a MASSIVE properties interface in Captivate 5, that won’t fit into the tiny Widget Parameters tab in Captivate 4? Or, what you just flat out don’t want to support Captivate 4? Well then my friends, let me introduce you to two properties that will save your day.
isCaptivate4, and isCaptivate5.
Shake hands now.
Nicely.
Nice to meet you isCaptivate4 and isCaptivate5. WHAT exactly are you?
isCaptivate4 and isCaptivate5 are properties in the widget classes (the widget classes are: StaticWidget, InteractiveWidget, and QuestionWidget) that give you a true or false value depending on which version of Captivate the widget is currently in. If your widget is inside Captivate 4, then isCaptivate4 will be true, and isCaptivate5 will be false. If your widget is inside Captivate 5 the opposite will be true. isCaptivate4 and isCaptivate5 (this is getting a little ridiculous, I’m going to call them the ‘isCaptivate properties’ from now on) only reflect the Captivate version they are in at Runtime (inside the published Captivate Movie) and inside the Properties Dialog; otherwise they default to Captivate 4. While this may seem a bit of a bummer, believe me when I say that the Runtime and Properties Dialog modes are the only places where there is enough difference between Captivate 4 and Captivate 5 to need to use these properties.
Okay, so WHY would I want use them?
When you want something to happen differently in one version of Captivate than the other. Captivate 5 has a fantastic new feature that allows you to set the size of the widget’s Properties Dialog. So if you have a superawesomefulcomplicated widget that demands at least 1000×1000 pixels of room for the Captivate Author to set its properties, then you’d set the propertiesDialogWidth and propertiesDialogHeight properties to 1000 each and your widget will be satiated.
However, what if someone tried to pull that widget into Captivate 4? The Widget Parameters tab isn’t nearly spacious enough to show the above, but seeing as this widget’s properties aren’t too complex, we can provide an alternative interface that will fit the smaller screen.
Using the isCaptivate properties, we can differentiate how the properties dialog will be set up in each version.
HOW do I use them?
Good question eager young space cadet! Typically, in an if statement. Like so:
1 2 3 4 5 | if (isCaptivate4) { // I'm in Captivate 4! } else { // I'm in Captivate 5! } |
Any code inside the first two {} brackets will be executed if your widget is in Captivate 4, any code inside the second {} brackets will be executed if your widget is inside Captivate 5, and any code outside this if else statement would be executed regardless of the Captivate version.
Of course this code would be inside either the enterRuntime() or enterPropertiesDialog() Template Method (See previous post for information on Template Methods).
Can you give me an example?
You know, I can!
The widget below will display a textField in the Properties Dialog that will tell you what version of Captivate the widget is running in.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | package { import widgetfactory.StaticWidget; import flash.text.TextField; public class MyVersionHipWidget extends StaticWidget { override protected function enterPropertiesDialog():void { var textField:TextField = new TextField(); addChild(textField); if (isCaptivate4) { textField.text = "I'm in Captivate 4!"; } else { drawPropertiesDialogBackground(); textField.text = "I'm in Captivate 5!"; } // Center Text Field textField.x = stage.stageWidth / 2 - textField.width / 2; textField.y = stage.stageHeight / 2 - textField.height / 2; } } } |
Notice how there’s a call to this ‘drawPropertiesDialogBackground’ method when we’re in Captivate 5? What this method does is make the background of the widget appear the same colour as the frame of the Widget Properties dialog in Captivate 5. The result being: your widget looks one with the Properties Dialog.
Check it out! Download this widget.
But isn’t stage mode different in Captivate 5 as well?
Captivate 5 does add the new isReadyForStageSnapShot property for use with stage mode. For those who don’t know, this new property tells Captivate whether or not the widget has finished drawing it’s stage preview. If it hasn’t, Captivate will give the widget a few milliseconds to keep drawing, then check again. Using this feature in Captivate 4 isn’t going to break anything though, Captivate 4 will just ignore it.
However, there is the case that you have a widget that will only work in Captivate 5, and if the widget has been inserted into Captivate 4 you want to give the Captivate Author fair warning that it’s not going to work. You could tell them in the Properties Dialog, but if you want to take it that little extra mile and display something on stage along the lines of…
…then what you could do is record the value of one of the isCaptivate properties into a Widget Property when you’re in the Properties Dialog.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | package { import widgetfactory.StaticWidget; public class IHateStage extends StaticWidget { // Properties Dialog wants to save the properties override protected function saveProperties():void { properties.isCaptivate4 = isCaptivate4; } override protected function enterStage():void { if (properties.isCaptivate4){ // Your widget's refusal of Captivate 4 code here. } else { // Your widget's love of Captivate 5 code here. } } } } |
However you use the isCaptivate properties, I’m sure you’ll find it gives your widget just that extra bit of pollish.

