2
* Copyright (c) 2007 Moses Gunesch
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
package org.goasap.utils {
23
import org.goasap.interfaces.IPlayable;
26
* Simple playable sequence, composed of groups of playable items.
28
* <p>A sequence can be built by passing any item that implements IPlayable
29
* and uses the standard set of PlayableBase play-state constants.
30
* Sequences are composed of SequenceStep instances, which can contain any
31
* number of child items such as LinearGo or PlayableGroup instances.
32
* Sequences dispatch SequenceEvent.ADVANCE each time a step completes and
33
* the play index advances to the next one, then GoEvent.COMPLETE when done.</p>
35
* <p>Other events dispatched include the GoEvent types START, STOP, PAUSE, RESUME,
36
* and CYCLE if the repeater.cycles property is set to a value other than one.</p>
38
* <p>All items in each step must dispatch COMPLETE or STOP before a Sequence
39
* will advance. This simple behavior can be limiting, especially with steps that
40
* are composed of groups of items. The Go utility package includes another
41
* sequencer called SequenceCA, which allows you to define different ways a sequence
42
* can advance: after a particular item in a step, a particular duration, after
43
* an event fires, etc.</p>
47
* @author Moses Gunesch
49
public class Sequence extends SequenceBase {
51
// -== Public Properties ==-
54
// length : uint [Read-only.]
55
// playIndex : int [Read-only.]
61
// skipTo(index:Number) : Boolean
64
* Returns the currently-playing SequenceStep.
65
* @return The currently-playing SequenceStep.
71
public function get currentStep() : SequenceStep {
72
return (super._getCurrentStep());
76
* Returns the final SequenceStep in the current sequence.
77
* @return The final SequenceStep in the current sequence.
83
public function get lastStep() : SequenceStep {
84
return (super._getLastStep());
87
// -== Public Methods ==-
92
* @param items Any number of IPlayable instances (e.g. LinearGo, PlayableGroup,
93
* SequenceStep) as separate arguments, or a single array of them.
95
public function Sequence(...items) {
96
super((items[ 0 ] is Array) ? items[ 0 ] : items);
100
* Retrieves any SequenceStep from the steps array.
101
* @param index An array index starting at 0.
102
* @return The SequenceStep instance at this index.
103
* @see #getStepByID()
107
public function getStepAt(index:int) : SequenceStep {
108
return (super._getStepAt(index) as SequenceStep);
112
* Locates a step with the specified playableID. To search within a step for a
113
* child by playableID, use the step instance's <code>getChildByID</code> method.
115
* @param playableID The step instance's playableID to search for.
116
* @return The SequenceStep with the matching playableID.
119
public function getStepByID(playableID:*) : SequenceStep {
120
return (super._getStepByID(playableID) as SequenceStep);
124
* Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, SequenceStep)
125
* to the end of the steps array, or optionally adds the instance into the last
126
* SequenceStep instead of adding it as a new step.
128
* <p>To remove a step use the <code>removeStepAt</code> method.</p>
130
* @param item The playable item to add to the sequence. Note
131
* that when new steps are added, any IPlayable
132
* instance of a type other than SequenceStep is
133
* automatically wrapped in a new SequenceStep.
135
* @param addToLastStep If true is passed the item is added to the last
136
* existing SequenceStep in the steps array. This
137
* option should be used with individual items that
138
* you want added as children to the SequenceStep.
139
* If there are no steps yet this option ignored and
140
* a new step is created.
142
* @return New length of the steps array.
144
public function addStep(item:IPlayable, addToLastStep:Boolean=false): int {
145
return (super._addStep(item, addToLastStep, SequenceStep));
149
* Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup,
150
* SequenceStep) at a specific index in the steps array. Calling this method
151
* stops any sequence play currently in progress.
153
* @param item The playable item to splice into the sequence.
155
* @param index Position in the array starting at 0, or a negative
156
* index like Array.splice.
158
* @return New length of the steps array.
160
public function addStepAt(item:IPlayable, index:int): int {
161
return (super._addStepAt(index, item, SequenceStep));
165
* Removes and returns the SequenceStep at a specific index from the steps
166
* array. Calling this method stops any sequence play currently in progress.
168
* @param index Position in the array starting at 0, or a negative
169
* index like Array.splice.
171
* @return The SequenceStep instance removed from the steps array.
173
public function removeStepAt(index:int): SequenceStep {
174
return (super._removeStepAt(index) as SequenceStep);
178
// length : uint [Read-only.]
179
// playIndex : int [Read-only.]
184
// resume() : Boolean
185
// skipTo(index:Number) : Boolean
b'\\ No newline at end of file'