Packageorg.goasap.utils
Classpublic class PlayableGroup
InheritancePlayableGroup Inheritance PlayableBase Inheritance flash.events.EventDispatcher
ImplementsIPlayable
SubclassesSequenceStep

Batch-play a set of items and receive an event when all of them have finished.

PlayableGroup accepts any IPlayable for its children, which can include tweens, other groups, sequences and so forth. The group listens for both GoEvent.STOP and GoEvent.COMPLETE events from its children, either of which are counted toward group completion.

The repeater property of PlayableGroup allows you to loop play any number of times, or indefinitely by setting its cycles to Repeater.INFINITE. GoEvent.CYCLE is dispatched on each loop and GoEvent.COMPLETE when finished. Other events dispatched include the GoEvent types START, STOP, PAUSE, and RESUME.



Public Properties
 PropertyDefined by
  children : Array
Get or set the children array.
PlayableGroup
  listenerCount : uint
[read-only] Determines the number of children currently being monitored for completion by the group.
PlayableGroup
 InheritedplayableID : *
An arbitrary id value for the convenient identification of any instance, automatically set to an instance count by this class.
PlayableBase
  repeater : Repeater
[read-only] The groups's Repeater instance, which may be used to make it loop and play more than one time.
PlayableGroup
 Inheritedstate : String
Returns a PlayStates constant.
PlayableBase
Protected Properties
 PropertyDefined by
 Inherited_playRetainer : Dictionary
[static] Memory-management: playable items that do not add themselves to GoEngine should use this property to store references to themselves during play.
PlayableBase
Public Methods
 MethodDefined by
  
PlayableGroup(... items)
Constructor.
PlayableGroup
  
addChild(item:IPlayable, adoptChildState:Boolean = false):Boolean
Adds a single IPlayable to the children array (duplicates are rejected) and syncs up the group and child play-states based on various conditions.
PlayableGroup
  
anyChildHasState(state:String):Boolean
Test whether any child has a particular PlayState.
PlayableGroup
  
getChildByID(playableID:*, deepSearch:Boolean = true):IPlayable
Searches for a child with the specified playableID.
PlayableGroup
  
pause():Boolean
Calls pause on all children.
PlayableGroup
  
removeChild(item:IPlayable):Boolean
Removes a single IPlayable from the children array.
PlayableGroup
  
resume():Boolean
Calls resume on all children.
PlayableGroup
  
skipTo(position:Number):Boolean
Calls skipTo on all children.
PlayableGroup
  
start():Boolean
Calls start on all children.
PlayableGroup
  
stop():Boolean
If the group is active, this method stops all child items and dispatches a GoEvent.STOP event.
PlayableGroup
 Inherited
toString():String
Appends the regular toString value with the instance's playableID.
PlayableBase
Events
 EventSummaryDefined by
   Dispatched after all children have dispatched a STOP or COMPLETE event.PlayableGroup
   Dispatched at the end the group if repeater.cycles is set to a value other than one, just before the group starts its next play cycle.PlayableGroup
   Dispatched when the group is paused successfully.PlayableGroup
   Dispatched when the group is resumed successfully.PlayableGroup
   Dispatched when the group starts.PlayableGroup
   Dispatched if the group is manually stopped.PlayableGroup
Property detail
childrenproperty
children:Array  [read-write]

Get or set the children array. Only IPlayable items are stored. Note that unlike the methods addChild and removeChild, setting this property will stop any group play currently in progress.

Implementation
    public function get children():Array
    public function set children(value:Array):void
listenerCountproperty 
listenerCount:uint  [read-only]

Determines the number of children currently being monitored for completion by the group.

Implementation
    public function get listenerCount():uint
repeaterproperty 
repeater:Repeater  [read-only]

The groups's Repeater instance, which may be used to make it loop and play more than one time.

The Repeater's cycles property can be set to an integer, or to Repeater.INFINITE or 0 to repeat indefinitely.

   var group:PlayableGroup = new PlayableGroup(tween1, tween2, tween3);
   group.repeater.cycles = 2;
   group.start();
   trace(group.repeater.currentCycle); // output: 0
   
Implementation
    public function get repeater():Repeater
Constructor detail
PlayableGroup()constructor
public function PlayableGroup(... items)

Constructor.

Parameters
... items — Any number of IPlayable items as separate arguments, or a single array of them.
Method detail
addChild()method
public function addChild(item:IPlayable, adoptChildState:Boolean = false):Boolean

Adds a single IPlayable to the children array (duplicates are rejected) and syncs up the group and child play-states based on various conditions.

If both the group and the item being added are STOPPED, the item is simply added to the children list.

If both items are PAUSED or PLAYING (including PLAYING_DELAY for children), the child is actively added to the group during play and will be monitored for completion along with others.

In other cases where the child's state mismatches the group's state, there are several behaviors available. Normally if the second parameter adoptChildState is left false, the child's mismatched state will be updated to match the group's state. This can result in it being stopped, paused, or started/resumed and monitored for completion along with other children. Passing true for adoptChildState results in updating the group's state to match the child's. This option could be used, for example, if you wanted to build a group of already-playing items without disrupting their play cycle with a start() call to the group.

Parameters
item:IPlayable — Any instance that implements IPlayable and uses PlayState constants.
 
adoptChildState:Boolean (default = false) — Makes this group change its play-state to match the state of the new child.

Returns
Boolean — Success.
anyChildHasState()method 
public function anyChildHasState(state:String):Boolean

Test whether any child has a particular PlayState.

   // Example: resume a paused group
   if ( myGroup.anyChildHasState(PlayStates.PlayStates.PAUSED) ) {
       myGroup.resume();
   }
   

Parameters
state:String

Returns
Boolean

See also

getChildByID()method 
public function getChildByID(playableID:*, deepSearch:Boolean = true):IPlayable

Searches for a child with the specified playableID.

Parameters
playableID:* — The item playableID to search for. (The item must have a property called playableID which is a general GoASAP convention established in PlayableBase.)
 
deepSearch:Boolean (default = true) — If child is not found in the group, this option runs a recursive search on any children that are PlayableGroup.

Returns
IPlayable — The SequenceStep with the matching playableID.
pause()method 
public function pause():Boolean

Calls pause on all children.

Returns
Boolean — Returns true only if all playing children in the group paused successfully and at least one child was paused.
removeChild()method 
public function removeChild(item:IPlayable):Boolean

Removes a single IPlayable from the children array.

Note that if play is in progress when a child is added it does not interrupt play and the child is monitored for completion along with others.

Parameters
item:IPlayable — Any instance that implements IPlayable and uses PlayState constants.

Returns
Boolean — Success.
resume()method 
public function resume():Boolean

Calls resume on all children.

Returns
Boolean — Returns true only if all paused children in the group resumed successfully and at least one child was resumed.
skipTo()method 
public function skipTo(position:Number):Boolean

Calls skipTo on all children.

Parameters
position:Number

Returns
Boolean — Returns true only if all children in the group skipTo the position successfully and at least one child was affected.
start()method 
public function start():Boolean

Calls start on all children.

If the group is active when this method is called, a stop call is automated which will result in a GoEVent.STOP event being dispatched.

Returns
Boolean — Returns true if any child in the group starts successfully.
stop()method 
public function stop():Boolean

If the group is active, this method stops all child items and dispatches a GoEvent.STOP event.

Returns
Boolean — Returns true only if all children in the group stop successfully.
Event detail
COMPLETEevent 
Event object type: org.goasap.events.GoEvent

Dispatched after all children have dispatched a STOP or COMPLETE event.

CYCLEevent  
Event object type: org.goasap.events.GoEvent

Dispatched at the end the group if repeater.cycles is set to a value other than one, just before the group starts its next play cycle.

PAUSEevent  
Event object type: org.goasap.events.GoEvent

Dispatched when the group is paused successfully.

RESUMEevent  
Event object type: org.goasap.events.GoEvent

Dispatched when the group is resumed successfully.

STARTevent  
Event object type: org.goasap.events.GoEvent

Dispatched when the group starts.

STOPevent  
Event object type: org.goasap.events.GoEvent

Dispatched if the group is manually stopped.