| Package | graphics.display |
| Class | public class TimelineScript |
| Inheritance | TimelineScript Object |
Example :
package examples
{
import graphics.display.TimelineScript;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.utils.clearTimeout;
import flash.utils.setTimeout;
public dynamic class TimelineScriptExample extends Sprite
{
public function TimelineScriptExample()
{
// stage
stage.align = StageAlign.TOP_LEFT ;
stage.scaleMode = StageScaleMode.NO_SCALE ;
stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
// MovieClip target
movieclip = getChildByName("mc") as MovieClip ;
// timeline script
timeline = new TimelineScript( movieclip , true ) ;
timeline.put( "start" , start ) ;
timeline.put( "middle" , pause ) ;
timeline.put( "finish" , finish ) ;
}
protected var id:uint ;
protected var movieclip:MovieClip ;
protected var timeline:TimelineScript ;
protected function pause():void
{
trace( "pause" ) ;
movieclip.stop() ;
if ( id )
{
clearTimeout( id ) ;
}
id = setTimeout( movieclip.play , 4000 ) ; // pause 4 s
}
protected function finish():void
{
trace( "finish" ) ;
movieclip.stop() ;
}
protected function keyDown( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.SPACE :
{
movieclip.gotoAndPlay(1) ; // start
break ;
}
case Keyboard.UP :
{
timeline.remove( "middle" ) ;
break ;
}
case Keyboard.DOWN :
{
timeline.clear() ;
break ;
}
}
}
protected function start():void
{
trace( "start" ) ;
}
}
}
| Property | Defined By | ||
|---|---|---|---|
| autoStop : Boolean
This boolean flag indicates if the specified MovieClip target reference is stopped. | TimelineScript | ||
| target : MovieClip
Indicates the target reference of this iterator. | TimelineScript | ||
| verbose : Boolean
The verbose mode flag. | TimelineScript | ||
| Method | Defined By | ||
|---|---|---|---|
TimelineScript(target:MovieClip = null, autoStop:Boolean = true)
Creates a new TimelineScript instance. | TimelineScript | ||
clear():void
Clear all scripts in the MovieClip target reference. | TimelineScript | ||
contains(index:*):Boolean
Indicates if a script is registerd with the specific frame index (label name or frame value). | TimelineScript | ||
initialize():void
Initialize all registered scripts in the target. | TimelineScript | ||
put(index:*, script:Function):Boolean
Registers a script function in the frame specified by the label or index value passed-in the first argument of the method. | TimelineScript | ||
remove(index:*):void
Unregisters a script function in the frame specified by the label or index value passed-in argument of the method. | TimelineScript | ||
resolve(label:String = null):int
Find the frame index of the specified passed-in label value in the MovieClip target. | TimelineScript | ||
| autoStop | property |
public var autoStop:BooleanThis boolean flag indicates if the specified MovieClip target reference is stopped.
| target | property |
target:MovieClipIndicates the target reference of this iterator.
public function get target():MovieClip public function set target(value:MovieClip):void| verbose | property |
public var verbose:BooleanThe verbose mode flag.
| TimelineScript | () | Constructor |
public function TimelineScript(target:MovieClip = null, autoStop:Boolean = true)Creates a new TimelineScript instance.
Parameterstarget:MovieClip (default = null) — The MovieClip reference of this iterator.
| |
autoStop:Boolean (default = true) — This boolean flag indicates if the specified MovieClip target reference is stopped (default true).
|
| clear | () | method |
public function clear():voidClear all scripts in the MovieClip target reference.
| contains | () | method |
public function contains(index:*):BooleanIndicates if a script is registerd with the specific frame index (label name or frame value).
Parameters
index:* — A String label name or an uint frame index value.
|
Boolean — true if the specific index is registered.
|
| initialize | () | method |
public function initialize():voidInitialize all registered scripts in the target.
| put | () | method |
public function put(index:*, script:Function):BooleanRegisters a script function in the frame specified by the label or index value passed-in the first argument of the method.
Parameters
index:* — A String label name or an uint frame index value.
| |
script:Function — The Function instruction to register.
|
Boolean — true if the register is success.
|
| remove | () | method |
public function remove(index:*):voidUnregisters a script function in the frame specified by the label or index value passed-in argument of the method.
Parameters
index:* — A String label name or an uint frame index value.
|
| resolve | () | method |
public function resolve(label:String = null):intFind the frame index of the specified passed-in label value in the MovieClip target.
Parameters
label:String (default = null) |
int |
ArgumentError — if the passed-in label value is null or empty.
| |
ArgumentError — if the passed-in label value don't exist in the MovieClip.
|