| Package | org.goasap.utils |
| Class | public class PlayableGroup |
| Inheritance | PlayableGroup PlayableBase flash.events.EventDispatcher |
| Implements | IPlayable |
| Subclasses | SequenceStep |
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.
| Property | Defined 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 | ||
![]() | playableID : *
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 | ||
![]() | state : String
Returns a PlayStates constant.
| PlayableBase | |
| Method | Defined by | ||
|---|---|---|---|
|
PlayableGroup(... items)
Constructor.
| PlayableGroup | ||
|
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 | ||
![]() |
toString():String
Appends the regular toString value with the instance's playableID.
| PlayableBase | |
| Event | Summary | Defined 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 | |||
| children | property |
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.
public function get children():Array
public function set children(value:Array):void
| listenerCount | property |
listenerCount:uint [read-only]Determines the number of children currently being monitored for completion by the group.
Implementation public function get listenerCount():uint
| repeater | property |
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: 0Implementation
public function get repeater():Repeater
| PlayableGroup | () | constructor |
public function PlayableGroup(... items)Constructor.
Parameters... items — Any number of IPlayable items as separate arguments,
or a single array of them.
|
| addChild | () | method |
public function addChild(item:IPlayable, adoptChildState:Boolean = false):BooleanAdds 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.
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.
|
Boolean — Success.
|
| anyChildHasState | () | method |
public function anyChildHasState(state:String):BooleanTest whether any child has a particular PlayState.
// Example: resume a paused group
if ( myGroup.anyChildHasState(PlayStates.PlayStates.PAUSED) ) {
myGroup.resume();
}
Parameters
state:String |
Boolean |
See also
| getChildByID | () | method |
public function getChildByID(playableID:*, deepSearch:Boolean = true):IPlayableSearches for a child with the specified playableID.
ParametersplayableID:* — 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.
|
IPlayable —
The SequenceStep with the matching playableID.
|
| pause | () | method |
public function pause():Boolean
Calls pause on all children.
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):BooleanRemoves 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.
Parametersitem:IPlayable — Any instance that implements IPlayable and uses PlayState constants.
|
Boolean — Success.
|
| resume | () | method |
public function resume():Boolean
Calls resume on all children.
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.
position:Number |
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():BooleanCalls 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.
Boolean — Returns true if any child in the group starts successfully.
|
| stop | () | method |
public function stop():BooleanIf the group is active, this method stops all child items and dispatches a GoEvent.STOP event.
ReturnsBoolean — Returns true only if all children in the group stop successfully.
|
| COMPLETE | event |
org.goasap.events.GoEvent
Dispatched after all children have dispatched a STOP or COMPLETE event.
| CYCLE | event |
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.
| PAUSE | event |
| RESUME | event |
| START | event |
| STOP | event |