Packagewidgetfactory.events
Classpublic class WidgetEvent
InheritanceWidgetEvent Inheritance flash.events.Event

The 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

widgetfactory.StaticWidget.currentWidgetMode


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Public Constants
 ConstantDefined 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
Property Detail
frameNumberproperty
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.


Implementation
    public function get frameNumber():Number

See also

isActOfUserproperty 
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.


Implementation
    public function get isActOfUser():Boolean

See also

isSuccessproperty 
isSuccess:Boolean  [read-only]

Used with the INTERACTIVE_WIDGET_SUBMITTED event. Indicates whether the Interactive Widget reported success or failure.


Implementation
    public function get isSuccess():Boolean

See also

itemNameproperty 
itemName:String  [read-only]

The item name of the widget that dispatched the event. Only used with INTERACTIVE_WIDGET_SUBMITTED and RESET_CRITERIA.


Implementation
    public function get itemName():String

See also

quizDataproperty 
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);
         }
         
         
For more information, see the QuizData class.


Implementation
    public function get quizData():QuizData

See also

slideLabelproperty 
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.


Implementation
    public function get slideLabel():String

See also

slideNumberproperty 
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.


Implementation
    public function get slideNumber():Number

See also

Constructor Detail
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.

Parameters
type: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)
Method Detail
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.

Returns
Event — A new WidgetEvent object that is identical to the original.
Constant Detail
ENTER_MOVIEConstant
public static const ENTER_MOVIE:String = enterMovie

Dispatched 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_DIALOGConstant 
public static const ENTER_PROPERTIES_DIALOG:String = enterPropertiesDialog

Dispatched 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_PREVIEWConstant 
public static const ENTER_PROPERTIES_DIALOG_PREVIEW:String = enterPropertiesDialogPreview

Dispatched 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_RUNTIMEConstant 
public static const ENTER_RUNTIME:String = enterRuntime

Dispatched 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_SLIDEConstant 
public static const ENTER_SLIDE:String = enterSlide

Dispatched 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_STAGEConstant 
public static const ENTER_STAGE:String = enterStage

Dispatched when Captivate displays your widget on the stage.

See also

ENTER_WIDGET_PANEL_PREVIEWConstant 
public static const ENTER_WIDGET_PANEL_PREVIEW:String = enterWidgetPanelPreview

Dispatched 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_RUNTIMEConstant 
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_SLIDEConstant 
public static const EXIT_SLIDE:String = exitSlide

Dispatched 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_SUBMITTEDConstant 
public static const INTERACTIVE_ITEM_SUBMITTED:String = interactiveItemSubmitted

Dispatched 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_SUBMITTEDConstant 
public static const INTERACTIVE_WIDGET_SUBMITTED:String = interactiveWidgetSubmitted

Dispatched 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_ENDEDConstant 
public static const MOVIE_ENDED:String = movieEnded

Dispatched when the published Captivate movie reaches its last frame.

Captivate 5 only.

PAUSEConstant 
public static const PAUSE:String = pause

Dispatched 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_FAILEDConstant 
public static const PROPERTIES_FAILED:String = propertiesFailed

Dispatched 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_CRITERIAConstant 
public static const RESET_CRITERIA:String = resetCriteria

Dispatched 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

RESUMEConstant 
public static const RESUME:String = resume

Dispatched 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_PROPERTIESConstant 
public static const SAVE_PROPERTIES:String = saveProperties

Dispatched 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