/** * Copyright (c) 2007 Moses Gunesch * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.goasap.utils { import org.goasap.interfaces.IPlayable; /** * Simple playable sequence, composed of groups of playable items. * *
A sequence can be built by passing any item that implements IPlayable * and uses the standard set of PlayableBase play-state constants. * Sequences are composed of SequenceStep instances, which can contain any * number of child items such as LinearGo or PlayableGroup instances. * Sequences dispatch SequenceEvent.ADVANCE each time a step completes and * the play index advances to the next one, then GoEvent.COMPLETE when done.
* *Other events dispatched include the GoEvent types START, STOP, PAUSE, RESUME, * and CYCLE if the repeater.cycles property is set to a value other than one.
* *All items in each step must dispatch COMPLETE or STOP before a Sequence * will advance. This simple behavior can be limiting, especially with steps that * are composed of groups of items. The Go utility package includes another * sequencer called SequenceCA, which allows you to define different ways a sequence * can advance: after a particular item in a step, a particular duration, after * an event fires, etc.
* * @see SequenceBase * @see SequenceCA * @author Moses Gunesch */ public class Sequence extends SequenceBase { // -== Public Properties ==- // Also in super: // length : uint [Read-only.] // playIndex : int [Read-only.] // steps : Array // start() : Boolean // stop() : Boolean // pause() : Boolean // resume() : Boolean // skipTo(index:Number) : Boolean /** * Returns the currently-playing SequenceStep. * @return The currently-playing SequenceStep. * @see #getStepAt() * @see #getStepByID() * @see #steps * @see #lastStep */ public function get currentStep() : SequenceStep { return (super._getCurrentStep()); } /** * Returns the final SequenceStep in the current sequence. * @return The final SequenceStep in the current sequence. * @see #getStepAt() * @see #getStepByID() * @see #steps * @see #currentStep */ public function get lastStep() : SequenceStep { return (super._getLastStep()); } // -== Public Methods ==- /** * Constructor. * * @param items Any number of IPlayable instances (e.g. LinearGo, PlayableGroup, * SequenceStep) as separate arguments, or a single array of them. */ public function Sequence(...items) { super((items[ 0 ] is Array) ? items[ 0 ] : items); } /** * Retrieves any SequenceStep from the steps array. * @param index An array index starting at 0. * @return The SequenceStep instance at this index. * @see #getStepByID() * @see #currentStep * @see #lastStep */ public function getStepAt(index:int) : SequenceStep { return (super._getStepAt(index) as SequenceStep); } /** * Locates a step with the specified playableID. To search within a step for a * child by playableID, use the step instance'sgetChildByID method.
*
* @param playableID The step instance's playableID to search for.
* @return The SequenceStep with the matching playableID.
* @see #getStepAt()
*/
public function getStepByID(playableID:*) : SequenceStep {
return (super._getStepByID(playableID) as SequenceStep);
}
/**
* Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, SequenceStep)
* to the end of the steps array, or optionally adds the instance into the last
* SequenceStep instead of adding it as a new step.
*
* To remove a step use the removeStepAt method.