Packageimpression.players
Classpublic class SWFVideoPlayer
InheritanceSWFVideoPlayer Inheritance RenderingPlayer Inheritance BasePlayer Inheritance flash.events.EventDispatcher

The SWFVideoPlayer supports playback of Flash .SWF animations.

These storyboards display a single animation. They typically include student text to accompany the animation and some type of control mechanism to manage (stop/restart) the animation. The shell handles this functionality -- the SWFVideoPlayer object itself is only responsible for playback of the animation. A number of methods and events are provided to allow the shell author to easily create custom playback controllers.

The SWFVideoPlayer supports both stepped and non-stepped ("traditional") animations. A stepped animation is a single file that contains several related movie clips, each occupying one frame on the root timeline of the main video file. These animations can be played individually (stepped mode) or continuously (one after the other).

The SWFVideoPlayer injects a reference to itself into the animation (as the .player property) at the root level of the .SWF. This gives animation creators additional control over the player allowing for advanced manipulation of the display.



Public Properties
 PropertyDefined By
 InheritedalwaysCheckComplete : Boolean
Specifies how the object should handle storyboard completion.
BasePlayer
  currentStep : int
Specifies the current step number.
SWFVideoPlayer
  isPlayable : Boolean
[read-only] Indicates whether the current state of the animation can be manipulated by the playback methods.
SWFVideoPlayer
  isSteppedVideo : Boolean
[read-only] Indicates whether the current storyboard is a stepped animation.
SWFVideoPlayer
 InheritednarrationComplete : Boolean
Indicates whether narration has finished playing.
BasePlayer
  renderingSurface : Sprite
[override] The object to render content on.
SWFVideoPlayer
 Inheritedresolver : AssetResolver
The AssetResolver to use to request external assets.
RenderingPlayer
  status : String
[read-only] Identifies the current status of the animation.
SWFVideoPlayer
  storyboard : Storyboard
[override] The storyboard associated with the player.
SWFVideoPlayer
  totalSteps : int
[read-only] Identifies the total number of steps in the loaded animation.
SWFVideoPlayer
Public Methods
 MethodDefined By
  
SWFVideoPlayer(renderingSurface:Sprite = null, resolver:AssetResolver = null)
Creates a new instance of the SWFVideoPlayer.
SWFVideoPlayer
 Inherited
Causes the player to examine the completion criteria for the current storyboard.
BasePlayer
 Inherited
clearStyle(style:String):void
Deletes a style property, reverting it back to its default value.
RenderingPlayer
  
[static] Creates a string describing the state of the storyboard.
SWFVideoPlayer
 Inherited
getStyle(style:String):Object
Retrieves a style property.
RenderingPlayer
  
[static] Retrieves the default style map for the SWFVideoPlayer.
SWFVideoPlayer
  
pause():void
Pauses or resumes playback at the current location.
SWFVideoPlayer
  
playStep():void
Plays the current step.
SWFVideoPlayer
  
playToEnd():void
Plays all steps, in sequence, from the current step without stopping.
SWFVideoPlayer
 Inherited
redraw():void
Forces a complete redraw of the content.
RenderingPlayer
  
[static] Removes all properties set by the player.
SWFVideoPlayer
  
setStoryboardState(sb:Storyboard, state:String):void
[static] Modifies the storyboard to match the described state passed.
SWFVideoPlayer
 Inherited
setStyle(style:String, value:Object):void
Sets a style property.
RenderingPlayer
Protected Methods
 MethodDefined By
  
[override] Removes any connections between the rendering surface and the player.
SWFVideoPlayer
  
[override] Removes all content from the surface.
SWFVideoPlayer
 Inherited
Initializes the storyboard.
BasePlayer
  
[override] Loads the storyboard.
SWFVideoPlayer
 Inherited
Adds a mask to the rendering surface if the maskRenderingSurface style property value is true.
RenderingPlayer
  
[override] Removes known completion criteria from the CompleteRemaining storyboard persisted property.
SWFVideoPlayer
 Inherited
Draws the background rectangle onto the rendering surface.
RenderingPlayer
  
[override] Renders the content onto the surface.
SWFVideoPlayer
  
[override] Performs cleanup actions when a storyboard is unloaded.
SWFVideoPlayer
Events
 Event Summary Defined By
 InheritedDispatched when the BasePlayer needs to resolve completion criteria beyond those defined for the class.BasePlayer
 InheritedDispatched when a storyboard is marked as complete.BasePlayer
 InheritedDispatched when the player begins to load external assets.RenderingPlayer
 InheritedDispatched when all external assets have finished loading.RenderingPlayer
 InheritedDispatched when some type of input or output failure occurs.RenderingPlayer
 InheritedDispatched after a storyboard is initialized.BasePlayer
 InheritedDispatched when some type of input or output failure occurs.RenderingPlayer
 InheritedDispatched when storyboard loading is complete.BasePlayer
 InheritedDispatched when a storyboard is loaded, but before any processing occurs.BasePlayer
 InheritedDispatched when some type of input or output failure occurs.RenderingPlayer
 InheritedDispatched before a storyboard is unloaded.BasePlayer
 InheritedDispatched when some type of input or output failure occurs.RenderingPlayer
  Dispatched when the ENTER_FRAME event of the current step clip is dispatched.SWFVideoPlayer
  Dispatched when the status of the animation changes.SWFVideoPlayer
Styles
 Style Description Defined By
 InheritedType: Boolean
Whether or not the primary asset should be resized when loaded to width x height.
RenderingPlayer
 InheritedType: Number
The background color transparency of the rendering surface.
RenderingPlayer
 InheritedType: uint Format: Color
The background color of the rendering surface.
RenderingPlayer
  
beginOnInit
Type: Boolean
Specifies when the player should start processing the loaded animation.

If this style value is true, the player will begin processing the animation when the loader object used to load the .SWF file dispatches its INIT event. If this style value is false, the player will begin processing when the loader dispatches its COMPLETE event.

The default value is false.
SWFVideoPlayer
 InheritedType: Boolean
The value of all assets' cacheAsBitmap property that the player should set once the asset is loaded.
RenderingPlayer
  
completeRequiresPlay
Type: Boolean
Specifies when a storyboard can be marked complete.

If this style value is true, the storyboard will not be marked complete by the player until the playStep() or playToEnd() methods have been invoked, regardless of the value of any other styles or property values. If this style value is false, the play methods do not need to be invoked for the storyboard to be marked complete.

The default value is false.
SWFVideoPlayer
 InheritedType: Object
The default LoaderContext object to use when assets are loaded.
RenderingPlayer
 InheritedType: Number Format: Length
The height of the rendering surface, in pixels.
RenderingPlayer
 InheritedType: Boolean
Whether or not the rendering surface should be masked to width x height.
RenderingPlayer
  
steppedAutoplayType
Type: String
Specifies what action should occur if the storyboard contains a stepped animation marked for autoplay.

This style value should be either the SWFVideoPlayer.STEPPED_AUTOPLAY_FIRST_STEP or the SWFVideoPlayer.STEPPED_AUTOPLAY_PLAY_TO_END property value.

The default value is SWFVideoPlayer.STEPPED_AUTOPLAY_FIRST_STEP.
SWFVideoPlayer
  
stepsCompleteWhen
Type: String
Specifies when a step should be marked complete.

If this style value is SWFVideoPlayer.AT_START, the step will be marked complete when the playhead for the current step moves to the first frame of the step. If this style value is SWFVideoPlayer.AT_END, the step will be marked complete when the playhead for the current step moves to the last frame of the step.

The default value is SWFVideoPlayer.AT_END.
SWFVideoPlayer
  
stepsStopAt
Type: String
Specifies where the playStep() method should stop the playhead when the step has finished playing.

If this style value is SWFVideoPlayer.AT_START, the player will move the playhead to the first frame of the next step and stop playback. If this style value is SWFVideoPlayer.AT_END, the player will stop playback on the last frame of the current step.

The default value is SWFVideoPlayer.AT_END.
SWFVideoPlayer
 InheritedType: Number Format: Length
The width of the rendering surface, in pixels.
RenderingPlayer
Public Constants
 ConstantDefined By
  AT_END : String = atEnd
[static] The playStep() method should stop playback on the last frame of the current step.
SWFVideoPlayer
  AT_START : String = atStart
[static] The playStep() method should stop playback on the first frame of the next step.
SWFVideoPlayer
  STEPPED_AUTOPLAY_FIRST_STEP : String = firstStep
[static] A storyboard containing a stepped animation that is marked as autoplay should only play the first step of the animation when first loaded.
SWFVideoPlayer
  STEPPED_AUTOPLAY_PLAY_TO_END : String = playToEnd
[static] A storyboard containing a stepped animation that is marked as autoplay should only all steps of the animation when first loaded.
SWFVideoPlayer
Property Detail
currentStepproperty
currentStep:int

Specifies the current step number.

If the storyboard property value is null, the isPlayable property value is false, or no file has been loaded, -1 is returned. If the status property value is VideoPlayerStatusTypes.EOF, totalSteps + 1 is returned.

When this property value is set to a number in (1 <= [value] <= totalSteps), the player moves the playhead to the first frame of the indicated step clip, stops playback, and dispatches a VideoStatusEvent.STATUS_CHANGE event with a status property value of VideoPlayerStatusTypes.STOPPPED. If the property value is set to totalSteps + 1, the player moves the playhead to the last frame of the last step clip, stops playback, and dispatches a VideoStatusEvent.STATUS_CHANGE event with a status property value of VideoPlayerStatusTypes.EOF.


Implementation
    public function get currentStep():int
    public function set currentStep(value:int):void

See also

isPlayableproperty 
isPlayable:Boolean  [read-only]

Indicates whether the current state of the animation can be manipulated by the playback methods.


Implementation
    public function get isPlayable():Boolean

See also

isSteppedVideoproperty 
isSteppedVideo:Boolean  [read-only]

Indicates whether the current storyboard is a stepped animation.


Implementation
    public function get isSteppedVideo():Boolean
renderingSurfaceproperty 
renderingSurface:Sprite[override]

The object to render content on.

If the existing rendering surface has existing content, it is not removed prior to setting the new surface. Note that any loading in progress will be cancelled, and all communication with and references to the player are removed.

You must manually invoke the redraw() method if you want to render the current storyboard onto the new surface.

If this property value is set to null, the player will dispatch a VideoStatusEvent.STATUS_CHANGE event with a status property value of VideoPlayerStatusTypes.NO_SURFACE.


Implementation
    public function get renderingSurface():Sprite
    public function set renderingSurface(value:Sprite):void
statusproperty 
status:String  [read-only]

Identifies the current status of the animation. This value will be one of the VideoPlayerStatusTypes constant values.


Implementation
    public function get status():String

See also

storyboardproperty 
storyboard:Storyboard[override]

The storyboard associated with the player.

If null is passed, the current storyboard is unloaded, the unload event is dispatched, and no further action occurs.

If a non-null storyboard object is passed, the following actions occur, in order:

  1. If the previously loaded storyboard is not null, the unload event is dispatched. If the event is not cancelled, the current storyboard is unloaded. If the event is cancelled, further processing stops.
  2. If the new storyboard is not null, the loadStart event is dispatched. If the event is not cancelled, the new storyboard is associated with the player. If the event is cancelled, further processing stops and the value of this property is set to null.
  3. If the value of the new storyboard's Initialized persisted property is false, the storyboard is initialized and the initialize event is dispatched.
  4. External content load begins. If any external content is specified, the contentLoadBegin event is dispatched.
  5. If external content finishes loading, the contentLoadEnd event is dispatched, followed by the loadComplete event.
  6. If the loadComplete event was dispatched, the checkForComplete() method is invoked. If all completion criteria have been met, the complete event is dispatched.

Note that the SWFVideoPlayer may raise one or move statusChange events during storyboard load.

If either the renderingSurface or resolver properties are null, the content will not be rendered, and no error will occur. Processing will continue as if all external assets have been loaded.


Implementation
    public function get storyboard():Storyboard
    public function set storyboard(value:Storyboard):void

See also

totalStepsproperty 
totalSteps:int  [read-only]

Identifies the total number of steps in the loaded animation.

If the storyboard property value is null, -1 is returned. If the isSteppedVideo property value is false, 1 is returned.


Implementation
    public function get totalSteps():int
Constructor Detail
SWFVideoPlayer()Constructor
public function SWFVideoPlayer(renderingSurface:Sprite = null, resolver:AssetResolver = null)

Creates a new instance of the SWFVideoPlayer.

Parameters
renderingSurface:Sprite (default = null) — The object to render content on.
 
resolver:AssetResolver (default = null) — The AssetResolver to use to request external assets.
Method Detail
detachSurface()method
override protected function detachSurface():void

Removes any connections between the rendering surface and the player.

This method is invoked by the player when a storyboard is unloaded, the redraw() method is invoked, or the renderingSurface property is changed. When detaching a rendering surface, the SWFVideoPlayer performs the following actions:

See also

eraseSurface()method 
override protected function eraseSurface():void

Removes all content from the surface.

This method is invoked by the player when a storyboard is unloaded or when the redraw() method is invoked. When erasing a rendering surface, the FlashObjectPlayer performs the following actions:

See also

getStoryboardState()method 
public static function getStoryboardState(sb:Storyboard):String

Creates a string describing the state of the storyboard.

This method returns a single character to describe the state of the storyboard. If the storyboard is marked complete, "c" is returned. If the storyboard has been initialized, but is not marked complete, "i" is returned. Otherwise "." is returned.

Note that this string only describes the state that the player is aware of. If the shell stores additional data in the storyboard, it is the shell's responsibility to store the additional data if it is needed.

Parameters

sb:Storyboard — The storyboard to describe the state of.

Returns
String — The state of the storyboard.
getStyleDefinition()method 
public static function getStyleDefinition():Object

Retrieves the default style map for the SWFVideoPlayer.

Returns
Object — Default styles object.
loadStoryboard()method 
override protected function loadStoryboard():void

Loads the storyboard.

This method is invoked by the storyboard property set method when a non-null storyboard object is loaded after initialization (if needed) occurs.

When loading a storyboard, the SWFVideoPlayer performs the following actions:

See also

pause()method 
public function pause():void

Pauses or resumes playback at the current location.

The specific behavior of this method depends on the value of the status property.

If the status property value is PLAYING_STEP, invoking this method will stop playback on the current frame. The player will dispatch a VideoStatusEvent.STATUS_CHANGE event with a status property value of VideoPlayerStatusTypes.STEP_PAUSED. If the status property value is PLAYING_TO_END, invoking this method will stop playback on the current frame. The player will dispatch a VideoStatusEvent.STATUS_CHANGE event with a status property value of VideoPlayerStatusTypes.PAUSED_TO_END.

If the status property value is STEP_PAUSED, invoking this method has the same effect as invoking the playStep() method. If the status property value is PAUSED_TO_END, invoking this method has the same effect as invoking the playToEnd() method.

For all other status property values, invoking this method has no effect.

See also

playStep()method 
public function playStep():void

Plays the current step.

The specific behavior of this method depends on the value of the status property.

If the status property value is one of the following, this method begins playback of the current step from the first frame, and will stop when playback of the current step is complete:

If the status property value is one of the following, this method begins playback of the current step from the current frame, and will stop when playback of the current step is complete:

For all other status property values, invoking this method has no effect.

If this method begins playback, the player will dispatch the VideoStatusEvent.STATUS_CHANGE event.

See also

playToEnd()method 
public function playToEnd():void

Plays all steps, in sequence, from the current step without stopping.

The specific behavior of this method depends on the value of the status property.

If the status property value is one of the following, this method begins playback of the current step from the current frame, and will stop when playback of the current step is complete:

For all other status property values, invoking this method has no effect.

If this method begins playback, the player will dispatch the VideoStatusEvent.STATUS_CHANGE event. As the playhead advances from step to step, additional status change events will be dispatched.

See also

removeCompleteRemainingCriteria()method 
override protected function removeCompleteRemainingCriteria():void

Removes known completion criteria from the CompleteRemaining storyboard persisted property.

This method is invoked by the checkForComplete() method if the value of the storyboard property is not null, and the complete event has not been dispatched since the storyboard was loaded.

In addition to the substrings processed by the BasePlayer, the SWFVideoPlayer will remove the following substrings from the completeRemaining persisted property:

SubstringMeaning
allStepsShown;All steps have been displayed.

See also

renderContent()method 
override protected function renderContent():void

Renders the content onto the surface.

To render content, the SWFVideoPlayer performs the following actions:

Note that the reference to the player is not injected into the animation until the loader responsible for loading the animation dispatches the Event.INIT event.

resetStoryboard()method 
public static function resetStoryboard(sb:Storyboard):void

Removes all properties set by the player.

Note that this method also removes interim completion properties used by the player, but not necessarily set by the player.

Parameters

sb:Storyboard — The storyboard to remove properties from.

This method removes the following properties from a storyboard:

  • Initialized
  • CompleteRemaining
  • Complete
  • NarrationComplete
  • The Complete property of each ChildElement object in the storyboard's Commands ChildElementCollection property, if it exists.
  • stepComplete

This method removes the following properties from each ChildElement in the storyboard's children collection:

  • Complete

setStoryboardState()method 
public static function setStoryboardState(sb:Storyboard, state:String):void

Modifies the storyboard to match the described state passed.

If the value of state is "c" (indicating a completed storyboard), interim completion criteria will be marked as complete in addition to the overall storyboard state.

State values created using a function other than getStoryboardState may not work.

Parameters

sb:Storyboard — The Storyboard object to modify.
 
state:String — A String created using the getStoryboardState() method containing the state to restore.

unloadStoryboard()method 
override protected function unloadStoryboard():void

Performs cleanup actions when a storyboard is unloaded.

This method is invoked by the storyboard property set method when the current value of the property is not null and the unload event has not been cancelled.

When unloading a storyboard, the SWFVideoPlayer performs the following actions:

See also

Event Detail
videoEnterFrame Event
Event Object Type: impression.events.VideoFrameEvent
VideoFrameEvent.type property = impression.events.VideoFrameEvent.ENTER_FRAME

Dispatched when the ENTER_FRAME event of the current step clip is dispatched.

The VideoFrameEvent.ENTER_FRAME constant defines the value of the type property of a frame event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
currentStepThe current step displayed by the player.
totalStepsThe total number of steps in the video.
currentStepClipThe MovieClip object that is the current step clip.
currentFrameThe value of the currentFrame property of the current step clip.
totalFramesThe value of the totalFrames property of the current step clip.
videoStatusChange Event  
Event Object Type: impression.events.VideoStatusEvent
VideoStatusEvent.type property = impression.events.VideoStatusEvent.STATUS_CHANGE

Dispatched when the status of the animation changes.

The VideoStatusEvent.STATUS_CHANGE constant defines the value of the type property of a status change event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
sbThe Storyboard object assigned to the target.
previousStepThe previous step displayed by the player.
currentStepThe current step displayed by the player.
totalStepsThe total number of steps in the video.
statusThe status of the player.
Constant Detail
AT_ENDConstant
public static const AT_END:String = atEnd

The playStep() method should stop playback on the last frame of the current step.

AT_STARTConstant 
public static const AT_START:String = atStart

The playStep() method should stop playback on the first frame of the next step.

STEPPED_AUTOPLAY_FIRST_STEPConstant 
public static const STEPPED_AUTOPLAY_FIRST_STEP:String = firstStep

A storyboard containing a stepped animation that is marked as autoplay should only play the first step of the animation when first loaded.

STEPPED_AUTOPLAY_PLAY_TO_ENDConstant 
public static const STEPPED_AUTOPLAY_PLAY_TO_END:String = playToEnd

A storyboard containing a stepped animation that is marked as autoplay should only all steps of the animation when first loaded.