| Package | widgetfactory.events |
| Class | public class WidgetEvent |
| Inheritance | WidgetEvent flash.events.Event |
WidgetEvent class dispatches events that concern every type of widget.
Most widget events notify you of the widget entering a Widget Mode. A Widget Mode refers to the widget's current location inside Captivate. There are several widget modes:
In each of these situations, your widget needs to play a different role.
For example, Properties Dialog Mode allows the Captivate author to customise the widget's settings.
However, it is the widget that needs to create and display those settings as a Graphic User Interface (GUI) for the author to interact with.
In Flash, we could use the design environment to build a GUI into a MovieClip.
Then you code the widget to listen for the ENTER_PROPERTIES_DIALOG event, and respond to it by making the GUI MovieClip visible,
thus making it possible for the Captivate Author to configure the widget.
package {
import widgetfactory.StaticWidget;
import widgetfactory.events.WidgetEvent;
public class Example extends StaticWidget {
public function Example () {
myWidgetGUI.visible = false; // Set the MovieClip that holds our GUI to invisible, so that it is not seen in any other modes.
addEventListener(WidgetEvent.ENTER_PROPERTIES_DIALOG, onEnterPropertiesDialog);
}
private function onEnterPropertiesDialog (event:WidgetEvent):void {
myWidgetGUI.visible = true; // Make it visible again so that the Author can configure the widget.
}
}
}
Once the Captivate Author has configured the widget settings in the GUI,
they must save them by clicking the dialog's 'OK' button (or 'Apply' button in Captivate 4).
Captivate then requests the widget's properties object, which will contain the Author's settings.
At this point the widget dispatches the SAVE_PROPERTIES event.
The widget developer codes the widget to listen for this event, and then write the settings from the GUI into the properties object.
The next example shows how this might be coded.
// ...Continued from previous example
private function onEnterPropertiesDialog (event:WidgetEvent):void {
myWidgetGUI.visible = true;
// Listen for the event
addEventListener(WidgetEvent.SAVE_PROPERTIES, onSaveProperties);
}
private function onSaveProperties (event:WidgetEvent):void {
properties.textToDisplay = myWidgetGUI.showThis_txt.text; // Presuming there's a text field in the GUI named 'showThis_txt'
// So on and so forth...
}
}
}
When the Captivate Author publishes their movie,
they want the widget to act according to the settings they configured in the Properties Dialog.
The ENTER_RUNTIME event tells you when the widget becomes visible in the output Captivate movie.
public function Example () {
addEventListener(WidgetEvent.ENTER_PROPERTIES_DIALOG, onEnterPropertiesDialog);
addEventListener(WidgetEvent.ENTER_RUNTIME, onEnterRuntime);
}
private function onEnterRuntime (event:WidgetEvent):void {
// Apply the property to a text field on stage.
display_txt.text = properties.textToDisplay;
}
For many of these events, the StaticWidget class has a corresponding Template Method.
All widget events are dispatched from the StaticWidget class.
See also
| Property | Defined By | ||
|---|---|---|---|
| frameNumber : Number [read-only]
The number of the frame in the Captivate Movie on which the event was dispatched. | WidgetEvent | ||
| isActOfUser : Boolean [read-only]
Returns true if the event was caused by something the user did, or false if it was caused by a Captivate operation. | WidgetEvent | ||
| isSuccess : Boolean [read-only]
Used with the INTERACTIVE_WIDGET_SUBMITTED event. | WidgetEvent | ||
| itemName : String [read-only]
The item name of the widget that dispatched the event. | WidgetEvent | ||
| quizData : QuizData [read-only]
quizData holds information about how the Captivate Author set up the quiz. | WidgetEvent | ||
| slideLabel : String [read-only]
The label of the slide on which the event was dispatched. | WidgetEvent | ||
| slideNumber : Number [read-only]
The number of the slide on which the event was dispatched. | WidgetEvent | ||
| Method | Defined By | ||
|---|---|---|---|
WidgetEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, frameNumber:Number, slideNumber:Number, slideLabel:String = null, isActOfUser:Boolean = false, quizData:QuizData = null, isSuccess:Boolean = false, itemName:String = null)
Creates an Event object to pass as a parameter to event listeners. | WidgetEvent | ||
clone():Event [override]
Creates a copy of the WidgetEvent object and sets the value of each property to match that of the original. | WidgetEvent | ||
| Constant | Defined By | ||
|---|---|---|---|
| ENTER_MOVIE : String = enterMovie [static]
Dispatched when the Captivate Movie begins. | WidgetEvent | ||
| ENTER_PROPERTIES_DIALOG : String = enterPropertiesDialog [static]
Dispatched when the Properties Dialog (Widget Parameters tab in Captivate 4) is opened. | WidgetEvent | ||
| ENTER_PROPERTIES_DIALOG_PREVIEW : String = enterPropertiesDialogPreview [static]
Dispatched when Captivate 4 displays your widget in the preview area of the Properties Dialog Widget tab. | WidgetEvent | ||
| ENTER_RUNTIME : String = enterRuntime [static]
Dispatched when the Captivate Movie enters the period in which this widget is supposed to appear. | WidgetEvent | ||
| ENTER_SLIDE : String = enterSlide [static]
Dispatched when the Captivate movie progresses into a new slide (except for the very first slide of the movie). | WidgetEvent | ||
| ENTER_STAGE : String = enterStage [static]
Dispatched when Captivate displays your widget on the stage. | WidgetEvent | ||
| ENTER_WIDGET_PANEL_PREVIEW : String = enterWidgetPanelPreview [static]
Dispatched when your widget is being previewed in the Widget Panel. | WidgetEvent | ||
| EXIT_RUNTIME : String = exitRuntime [static]
Dispatched when the Captivate Movie leaves the period of time in which the widget is supposed to appear. | WidgetEvent | ||
| EXIT_SLIDE : String = exitSlide [static]
Dispatched when the Captivate movie has reached the last frame of the current slide, and is about to move on to the next slide. | WidgetEvent | ||
| INTERACTIVE_ITEM_SUBMITTED : String = interactiveItemSubmitted [static]
Dispatched whenever an interactive object sends information back to Captivate. | WidgetEvent | ||
| INTERACTIVE_WIDGET_SUBMITTED : String = interactiveWidgetSubmitted [static]
Dispatched when a WidgetFactory Interactive Widget reports a criteria. | WidgetEvent | ||
| MOVIE_ENDED : String = movieEnded [static]
Dispatched when the published Captivate movie reaches its last frame. | WidgetEvent | ||
| PAUSE : String = pause [static]
Dispatched whenever the Captivate movie is paused. | WidgetEvent | ||
| PROPERTIES_FAILED : String = propertiesFailed [static]
Dispatched if the Widget Properties do not load correctly. | WidgetEvent | ||
| RESET_CRITERIA : String = resetCriteria [static]
Dispatched when a WidgetFactory Interactive Widget calls its resetCriteria method. | WidgetEvent | ||
| RESUME : String = resume [static]
Dispatched when the movie resumes after being paused. | WidgetEvent | ||
| SAVE_PROPERTIES : String = saveProperties [static]
Dispatched when the OK button inside the Properties Dialog is clicked. | WidgetEvent | ||
| frameNumber | property |
frameNumber:Number [read-only] The number of the frame in the Captivate Movie on which the event was dispatched.
This property is used with the events listed under See also.
public function get frameNumber():NumberSee also
| isActOfUser | property |
isActOfUser:Boolean [read-only] Returns true if the event was caused by something the user did, or false if it was caused by a Captivate operation.
This property is used with the events listed under See also.
public function get isActOfUser():BooleanSee also
| isSuccess | property |
isSuccess:Boolean [read-only]
Used with the INTERACTIVE_WIDGET_SUBMITTED event. Indicates whether the Interactive Widget
reported success or failure.
public function get isSuccess():BooleanSee also
| itemName | property |
itemName:String [read-only]
The item name of the widget that dispatched the event.
Only used with INTERACTIVE_WIDGET_SUBMITTED and RESET_CRITERIA.
public function get itemName():StringSee also
| quizData | property |
quizData:QuizData [read-only] quizData holds information about how the Captivate Author set up the quiz.
Access to this property is only available when responding to the QuestionWidgetEvent.QUESTION_SUBMITTED,
and WidgetEvent.INTERACTIVE_ITEM_SUBMITTED events.
addEventListener(WidgetEvent.INTERACTIVE_ITEM_SUBMITTED, onInteractiveItemSubmitted)
private function onInteractiveItemSubmitted(e:WidgetEvent):void
{
trace(e.quizData);
trace(e.quizData.questionAnsweredCorrectly);
}
public function get quizData():QuizDataSee also
| slideLabel | property |
slideLabel:String [read-only] The label of the slide on which the event was dispatched.
This property is used with the events listed under See also.
public function get slideLabel():StringSee also
| slideNumber | property |
slideNumber:Number [read-only] The number of the slide on which the event was dispatched.
This property is used with the events listed under See also.
public function get slideNumber():NumberSee also
| WidgetEvent | () | Constructor |
public function WidgetEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, frameNumber:Number, slideNumber:Number, slideLabel:String = null, isActOfUser:Boolean = false, quizData:QuizData = null, isSuccess:Boolean = false, itemName:String = null)Creates an Event object to pass as a parameter to event listeners.
Parameterstype:String — The type of the event.
| |
bubbles:Boolean (default = false) — Determines whether the Event object participates in the bubbling stage of the event flow (or something). The default value is false.
| |
cancelable:Boolean (default = false) — Determines whether the Event object can be canceled. The default values is false.
| |
frameNumber:Number (default = NaN) — The current frame number of the Captivate Movie.
| |
slideNumber:Number (default = NaN) — The number of the current slide in the Captivate Movie.
| |
slideLabel:String (default = null) — The label of the current slide in the Captivate Movie.
| |
isActOfUser:Boolean (default = false) — Indicates if the event was caused by a user action, and not automated Captivate operation.
| |
quizData:QuizData (default = null) | |
isSuccess:Boolean (default = false) | |
itemName:String (default = null) |
| clone | () | method |
override public function clone():Event
Creates a copy of the WidgetEvent object and sets the value of each property to match that of the original.
Event — A new WidgetEvent object that is identical to the original.
|
| ENTER_MOVIE | Constant |
public static const ENTER_MOVIE:String = enterMovieDispatched when the Captivate Movie begins.
Widgets are actually present in the Captivate Movie from its very start, either the first frame or very near thereafter.
However, they're only visible become when the ENTER_RUNTIME event is dispatched.
By responding to this event (ENTER_MOVIE), you can have your widget perform operations before it becomes visible.
Applies to all Captivate 5 widgets, but only Captivate 4 externalized widgets.
See also
| ENTER_PROPERTIES_DIALOG | Constant |
public static const ENTER_PROPERTIES_DIALOG:String = enterPropertiesDialogDispatched when the Properties Dialog (Widget Parameters tab in Captivate 4) is opened.
The widget .swf is embedded into the Properties Dialog. This gives you an opportunity to create a Graphic User Interface inside your widget .swf to allow the Captivate author to customize settings that change the appearance and/or behaviour of the widget.
Note: This is the only widget mode where you can write Widget Properties

Because Captivate 4 does not allow you to change the size of the Widget Parameters tab, you can create an alternative GUI for when the widget is used in Captivate 4.
Use the isCaptivate4 and isCaptivate5 properties from the StaticWidget class to determine which GUI you will display.
When this event is dispatched, the WidgetEvent class records the current frame number, slide number and slide label, and makes these values available to you via the frameNumber, slideNumber, and slideLabel properties.
See also
| ENTER_PROPERTIES_DIALOG_PREVIEW | Constant |
public static const ENTER_PROPERTIES_DIALOG_PREVIEW:String = enterPropertiesDialogPreviewDispatched when Captivate 4 displays your widget in the preview area of the Properties Dialog Widget tab.
This particular preview area does not exist in Captivate 5. In Captivate 4, the properties window is opened by right clicking the widget, and selecting 'properties' from the context menu.

Captivate 4 only.
See also
| ENTER_RUNTIME | Constant |
public static const ENTER_RUNTIME:String = enterRuntimeDispatched when the Captivate Movie enters the period in which this widget is supposed to appear.
If the Captivate Author added the widget to the third slide of the movie and set it to appear nine seconds into the slide,
then, in the published movie, the ENTER_RUNTIME event would be dispatched nine seconds into the third slide,
even though the widget is loaded and running from the very first frame of the movie.

Also, if the user scrubs or jumps the movie to a point within the widget's active period, then this event will be dispatched again. This is assuming that the widget has exited runtime first.
See also
| ENTER_SLIDE | Constant |
public static const ENTER_SLIDE:String = enterSlideDispatched when the Captivate movie progresses into a new slide (except for the very first slide of the movie).
When this event is dispatched, the WidgetEvent class records the current frame number, slide number and slide label, and makes these values available to you via the frameNumber, slideNumber, and slideLabel properties.
Captivate 5 only.
See also
| ENTER_STAGE | Constant |
public static const ENTER_STAGE:String = enterStageDispatched when Captivate displays your widget on the stage.

See also
| ENTER_WIDGET_PANEL_PREVIEW | Constant |
public static const ENTER_WIDGET_PANEL_PREVIEW:String = enterWidgetPanelPreviewDispatched when your widget is being previewed in the Widget Panel.
Here would be a good place to set up a splash screen for your widget, so that potential users can see what the widget will look like.

See also
| EXIT_RUNTIME | Constant |
public static const EXIT_RUNTIME:String = exitRuntime
Dispatched when the Captivate Movie leaves the period of time in which the widget is supposed to appear.
This is assuming the ENTER_RUNTIME event has been dispatched.
This event paired with ENTER_RUNTIME allow you to load and unload the widget so as to reduce
the load on the movie while it is not being viewed.
For more information on how Template Methods work, see this post.
See also
| EXIT_SLIDE | Constant |
public static const EXIT_SLIDE:String = exitSlideDispatched when the Captivate movie has reached the last frame of the current slide, and is about to move on to the next slide.
When this event is dispatched, the WidgetEvent class records the current frame number, slide number and slide label, and makes these values available to you via the frameNumber, slideNumber, and slideLabel properties.
Captivate 5 only.
See also
| INTERACTIVE_ITEM_SUBMITTED | Constant |
public static const INTERACTIVE_ITEM_SUBMITTED:String = interactiveItemSubmittedDispatched whenever an interactive object sends information back to Captivate.
A number of items in Captivate are considered to be 'Interactive', such as buttons, click boxes, and Interactive Widgets. When the user has interacted with one of these objects, the object sends information back to Captivate. For example when clicked, a button sends information back to Captivate about the slide that it is on, and scoring information (if it is set up to report scoring).
When this event is dispatched, the WidgetEvent class records the current frame number and slide number,
and makes these values available to you via the frameNumber and slideNumber properties.
If the Interactive Item it is responding to is set up to be part of the quiz...

Then information about the quiz will be collected and made available from the event's quizData property.
Captivate 5 only.
See also
| INTERACTIVE_WIDGET_SUBMITTED | Constant |
public static const INTERACTIVE_WIDGET_SUBMITTED:String = interactiveWidgetSubmittedDispatched when a WidgetFactory Interactive Widget reports a criteria.
This event bubbles. So to be notified of any Interactive Widgets that are reporting a criteria on a particular slide,
listen for this event on that slide. You can then use the itemName property to distinguish which widget
it was that dispatched the event.
However, because of the way that Captivate currently works, it is impossible to strongly cast a custom event that has been dispatched from another widget. So instead of writing the event handler like this:
private function onInteractiveWidgetSubmitted(event:WidgetEvent):void
{
}
Cast the event parameter as an Object and not a WidgetEvent, like so:
private function onInteractiveWidgetSubmitted(event:Object):void
{
}
On the down side, this means that there is no strong casting. On the up side it doesn't cause an Error! If you're a real stickler for strong typing, then look into creating a proxy (but this is not required to get it to work).
The isSuccess property indicates if the Interactive Widget reported success or failure.
See also
| MOVIE_ENDED | Constant |
public static const MOVIE_ENDED:String = movieEndedDispatched when the published Captivate movie reaches its last frame.
Captivate 5 only.
| PAUSE | Constant |
public static const PAUSE:String = pauseDispatched whenever the Captivate movie is paused.
This event is dispatched both when the user clicks the pause button on the playbar, and when something inside the movie (such as a question) pauses the movie.
You can distinguish between whether it was the user, or Captivate, that paused the movie via the isActOfUser property.
When this event is dispatched, the WidgetEvent class records the current frame number and slide number, and makes these values available to you via the frameNumber and slideNumber properties.
Captivate 5 only.
See also
| PROPERTIES_FAILED | Constant |
public static const PROPERTIES_FAILED:String = propertiesFailedDispatched if the Widget Properties do not load correctly. This event is for debugging purposes.
This error is usually caused by trying to write something to Widget Properties which is not an object, array, number, string, boolean, or null.
See also
| RESET_CRITERIA | Constant |
public static const RESET_CRITERIA:String = resetCriteriaDispatched when a WidgetFactory Interactive Widget calls its resetCriteria method.
This event bubbles. So to be notified of any Interactive Widgets that are resetting their criteria on a particular slide,
listen for this event on that slide. You can then use the itemName property to distinguish which widget
it was that dispatched the event.
The same typing issue that happens with the INTERACTIVE_WIDGET_SUBMITTED event happens with this one.
See also
| RESUME | Constant |
public static const RESUME:String = resumeDispatched when the movie resumes after being paused.
This event is dispatched when the user presses play on the playbar, or if something inside the movie (such as answering a question) automatically causes the movie to resume.
You can distinguish between whether it was the user, or Captivate, that resumed the movie via the isActOfUser property.
When this event is dispatched, the WidgetEvent class records the current frame number and slide number, and makes these values available to you via the frameNumber and slideNumber properties.
Captivate 5 only.
See also
| SAVE_PROPERTIES | Constant |
public static const SAVE_PROPERTIES:String = savePropertiesDispatched when the OK button inside the Properties Dialog is clicked.
In Captivate 4, the Widget Parameters tab has an extra button for 'Apply'.
This dispatches the SAVE_PROPERTIES event, but does not close down the Widget Parameters tab.
This event is still considered to be part of the Properties Dialog Mode.
The idea is that in responding to this event, you save into Widget Properties the settings that the Captivate Author made in your Graphic User Interface.
For more information on how to save these settings, see the properties property in the StaticWidget class

See also