Packagegraphics.display
Classpublic class TimelineScript
InheritanceTimelineScript Inheritance Object

The TimeLineScript class use composition to register script function over MovieClip timelines.

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" ) ;
             }
         }
     }
     



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
Property Detail
autoStopproperty
public var autoStop:Boolean

This boolean flag indicates if the specified MovieClip target reference is stopped.

targetproperty 
target:MovieClip

Indicates the target reference of this iterator.


Implementation
    public function get target():MovieClip
    public function set target(value:MovieClip):void
verboseproperty 
public var verbose:Boolean

The verbose mode flag.

Constructor Detail
TimelineScript()Constructor
public function TimelineScript(target:MovieClip = null, autoStop:Boolean = true)

Creates a new TimelineScript instance.

Parameters
target: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).
Method Detail
clear()method
public function clear():void

Clear all scripts in the MovieClip target reference.

contains()method 
public function contains(index:*):Boolean

Indicates 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.

Returns
Booleantrue if the specific index is registered.
initialize()method 
public function initialize():void

Initialize all registered scripts in the target.

put()method 
public function 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.

Parameters

index:* — A String label name or an uint frame index value.
 
script:Function — The Function instruction to register.

Returns
Boolean — true if the register is success.
remove()method 
public function remove(index:*):void

Unregisters 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):int

Find the frame index of the specified passed-in label value in the MovieClip target.

Parameters

label:String (default = null)

Returns
int

Throws
ArgumentError — if the passed-in label value is null or empty.
 
ArgumentError — if the passed-in label value don't exist in the MovieClip.