## Sequencer Control

This section contains reference material for the Sequencer control and its methods and events, plus the following additional topics:

- Sequencer Control VBScript Example
- Action Set

The Sequencer control provides timing and sequencing services for action sets, scripts used to control Microsoft® ActiveX™ Controls or scripts on the page. The Sequencer control calls Microsoft JScript™, Microsoft Visual Basic(r) Scripting Edition (VBScript) or other Web scripts.

These procedures are called by the Sequencer control's At Method and can be performed once or they can be looped by the Sequencer control. The Sequencer control calls the named script with the parameter string and the resolved parameter string is executed. Note that this means unresolved parameters don't get executed.

To use the sequencer object, you must first instantiate it on the HTML page, as shown in the following syntax:

Syntax

    <OBJECT id=object
    	STYLE=""
    	CLASSID=clsid:B0A6BAE2-AAF0-11d0-A152-00A0C908DB96>
    </OBJECT>

Parameters

object | Name of the Sequencer control, to be used in script.

Sequencer Control Methods

Method | Description
At | Specifies a new action in the action set.
Pause | Stops action set playback at current position. Keeps time pointer and queue.
Play | Starts the action set (if stopped). Resumes sequencer playback if sequencer is paused. Ignored if sequencer is playing.
Seek | Changes the current playback position of the action set to a new, specified time.
Stop | Stops action set playback, resets its playback position to the beginning.

Sequencer Control Events

Event | Description
oninit | Occurs when sequencer is first completely loaded into memory.
onpause | Occurs when action set playback has been paused.
onplay | Occurs when the action set has started playback. This event is only called when the action set starts playback from a stopped or paused state, not when a currently playing action set loops back to the beginning to repeat playback.
onseek | Occurs after the Seek method call has been completed.
onstop | Occurs when the action set playback ends or is stopped.

For optimal performance, use only one sequencer on a page with a single action set that calls a lot of actions. You can run multiple sequencers that each execute fewer action sets simultaneously but will get better performance with a single sequencer executing a larger number of action sets.

As the page is loaded, the sequencers used are loaded into memory. You can use the oninit Event to ensure that the sequencers are fully loaded before starting their playback.

Sequencer Control VBScript Example

This sample demonstrates how to use the Sequencer control in VBScript. It rotates text, and allows the user to stop and restart the rotation by clicking a button.

    <HTML>
    <HEAD>
    <TITLE>Microsoft DirectAnimation Controls - Sequencer</TITLE>

    <SCRIPT LANGUAGE=VBSCRIPT>

    Sub Window_OnLoad
    	call sgMSDHTML.SetIdentity
    	Button1.value="Pause"
    End Sub

    Sub Seq_oninit
    	call seq("ActionSet1").At(0.000, "RotateAll",-1, 0.050, 1)
    	Call Seq("ActionSet1").Play
    End Sub

    Sub RotateAll
    	Call sgMSDHTML.Rotate(0,9,2)
    End Sub

    Sub Start
    	Select Case Button1.value
    	Case "Play"
    		Call Seq("ActionSet1").Play
    		Button1.value="Pause"
    	Case "Pause"
    		Call Seq("ActionSet1").Pause
    		Button1.value="Play"
    	End Select
    End Sub

    </SCRIPT>
    </HEAD>

    <BODY BGCOLOR=BLACK>

    <OBJECT ID=sgMSDHTML
    STYLE="POSITION: ABSOLUTE; HEIGHT:300;WIDTH:450;TOP:100;LEFT:60;VISIBILITY:VISIBLE; ZINDEX:-1"
    CLASSID="CLSID:369303C2-D7AC-11d0-89D5-00A0C90833E6">
    <PARAM NAME="Line0001" VALUE="SetLineColor(255,255,255)">
    <PARAM NAME="Line0002" VALUE="SetFillColor(0,0,255)">
    <PARAM NAME="Line0003" VALUE="SetFillSTYLE(1)">
    <PARAM NAME="Line0004" VALUE="SetLineSTYLE(1)">
    <PARAM NAME="Line0005" VALUE="SetFont('Verdana',60,650,0,0,0)">
    <PARAM NAME="Line0006" VALUE="Text('Microsoft', -120, -100, 0)">
    <PARAM NAME="Line0007" VALUE="Text('Dynamic', -120, -50, 0)">
    <PARAM NAME="Line0008" VALUE="Text('HTML', -90, 0, 0)">
    <PARAM NAME="Line0009" VALUE="Text('Multimedia', -120, 50, 0)">
    </OBJECT>

    <OBJECT ID="Seq"
    	CLASSID="CLSID:B0A6BAE2-AAF0-11d0-A152-00A0C908DB96"
    	STYLE="WIDTH:2;HEIGHT:2">
    </OBJECT>

    <INPUT TYPE=button ID="Button1"
    STYLE="POSITION:ABSOLUTE; TOP:10; LEFT:10; z-index:2; VALUE=""; OnClick="Start">

    </BODY>
    </HTML>

Action Set

An action set is a logical grouping of named procedures that are used to control the timing and behavior of objects on the page. Action sets have the following properties:

Name | Description
PlayState | Retrieves the current playback state of the action set: 0=stopped, 1=playing, 2=paused. Read-only at run time.
Time | Retrieves the elapsed time in format seconds/milliseconds (SS.MSS) since the start of action set playback, including iterations. The default setting is zero. Read-only at run time.

###

PlayState Property

Action Set

Retrieves the state of the sequencer. Read-only at run time.

VBScript Syntax
playstate=object(
"actionsetname"
) .PlayState

JScript Syntax
playstate=object.item(
"actionsetname"
) .Playstate

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.

##### Return Values

Returns an integer that indicates the sequencer's play state. Possible values are 0 (stopped), 1 (playing) or 2 (paused).

###

Time Property

Action Set

Represents the amount of time since the start of the sequencer's playback. Read-only at run time.

VBScript Syntax
Time=object(
"actionsetname"
) .Time

JScript Syntax
Time=object.item(
"actionsetname"
) .Time

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.

##### Return Values

Returns a floating-point value that contains the elapsed sequencer playback time in the format seconds.milliseconds (SS.MSS).

###

At Method

Sequencer Control

Specifies an action to take place within an action set.

VBScript Syntax
call object(
"actionsetname"
).At(
time,
"script",
[loop,
interval,
tiebreak,
drop threshold]
)

JScript Syntax
object.item(
"actionsetname"
).At(
time,
"script",
[loop,
interval,
tie break,
drop threshold]
);

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.
time
  Required. Double value in seconds.milliseconds (SS.MSS) format. Sets the start time for the specified action.
script
  Required. Text string identifying the named procedure to be called. Can pass parameters as part of the script call, for example, script(param1)
loop
  Optional. Integer. Sets the loop count for this action. The default is 1. If set to –1, looping is infinite. Any negative number other than –1 will be treated as 0. Zero loop count value prevents execution. You can use this to programmatically halt action set execution.
interval
  Optional. Double value in seconds.milliseconds (SS.MSS) format. Sets the delay between iterations of the specified action. Minimum interval resolution is 20 milliseconds (00.020). The default is 33 milliseconds (00.033), equivalent to 30 frames per second.
tie break
  Optional. Integer whose value can be –1, 0, or a positive integer. The default is –1. Sets the priority for the action. In the event that two actions happen at the same time, the action with the lower tie break number will be performed first. Zero is the highest priority action that can be dropped; –1 is the lowest-priority action and will be executed last.
drop threshold
  Optional. Double value in seconds.milliseconds (SS.MSS) format. Sets the time by which the action must be performed before it is dropped from the queue. The default value is for the action to never be dropped (–1.000).

##### Remarks

The drop threshold parameter is useful for optimizing sequencer performance by streamlining the number of actions that the sequencer has to perform at any given moment; for instance, when starting up a complex action set. Thoughtful use of this parameter can keep the sequencer from slowing down or speeding up from backlog of actions to be executed, and keep the timing of actions within reasonable tolerances.

###

Pause Method

Sequencer Control

Stops the sequencer's playback, but maintains the current playback position.

VBScript syntax
call object(
"actionsetname"
) .Pause

JScript Syntax
object.item(
"actionsetname"
).Pause( )

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.

###

Play Method

Sequencer Control

Starts the sequencer or resumes it if the sequencer was paused. If the sequencer is playing, the call is ignored.

VBScript Syntax
call object(
"actionsetname"
) .Play

JScript Syntax
object.item(
"actionsetname"
).Play( )

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.

##### Remarks

The following example starts a sequencer described by the Seq object when the page loads. This sequencer calls the MoveButton action set at time 0, and calls the named procedure MoveButton.

    <SCRIPT LANGUAGE=vbscript>
    <!--
    Sub window_onLoad
    	Call Seq("MoveButton").Play
    End Sub
    -->
    </SCRIPT>

###

Seek Method

Sequencer Control

Changes the current playback position of the Sequencer control to another specified point in playback.

VBScript Syntax
call object(
"actionsetname"
).Seek(
time
)

JScript Syntax
object.item(
"actionsetname"
).Seek(
time
)

##### Parameters

object
  Name of sequencer.
actionsetname
  Name of the action set.
time
  New time for sequencer to continue playback.

###

Stop Method

Sequencer Control

Stops the sequencer and resets its position to the beginning.

VBScript Syntax
call object(
"actionsetname"
) .Stop

JScript Syntax
object.item(
"actionsetname"
).Stop( )

##### Parameters

object
  Name of the sequencer.
actionsetname
  Name of the action set.

##### Remarks

The following code stops the sequence when the btnEnd button is clicked.

    <SCRIPT LANGUAGE=vbscript>
    <!--
    Sub btnEnd_OnClick
    	Call Seq("MoveButton").Stop
    End Sub
    -->
    </SCRIPT>

The sequencer automatically stops when the page is unloaded.

###

oninit Event

Sequencer Control

Called when the sequencer has finished loading into memory and the page is loaded. At this point, the specified script is run. This event is generally used to load the rest of the procedures to be run on the client side.

VBScript Syntax
Sub object_oninit
script
End Sub

JScript Syntax
<script language="javascript" for="object" event="oninit">
<!--
script
//--><script>

##### Parameters

object
  Name of the sequencer to be used in script.
script
  Script to be run.

##### Remarks

The following example shows the oninit event used to play SeqMgr once it has finished loading the other sequencers that it controls. In the example, SeqMgr controls Seq1_Action1.

    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub SeqMgr_oninit()
    	Call SeqMgr("ActionSet1").At(0.000,"Seq1_Action1",300,0.100,1,100.000)
    	Call SeqMgr("ActionSet1").Play
    End Sub
    -->
    </SCRIPT>

###

onpause Event

Sequencer Control

Called when the sequencer playback is paused. At this point, the specified script is run.

VBScript Syntax
Sub object_onpause(
actionsetname
)
script
End Sub

JScript Syntax
<script language="javascript" for="object" event="onpause(
actionsetname
) ">
<!--
script
//--><script>

##### Parameters

object
  Name of the paused sequencer.
actionsetname
  Name of the action set that has been paused because the sequencer is paused.

##### Remarks

In the following example, actionsetname is a variable set to the name of the action set that was last paused. The example tests the actionsetname parameter passed and conditionally executes a script based on which action set has been paused.

    Sub Sequencername_onpause(actionsetname)
    	If actionsetname="ActionSet1" then
    		button1.value="Play"
    	Else
    		button1.value="Pause"
    	Endif
    End Sub

###

onplay Event

Sequencer Control

Occurs when the sequencer starts playback. At this point, the specified script code is run.

VBScript Syntax
Sub SequencerName_onplay(
actionsetname
)
script
End Sub

JScript Syntax
<script language="javascript" for="object" event="onplay(
actionsetname
) ">
<!--
script
//--><script>

##### Parameters

object
  Name of the sequencer played.
actionsetname
  Name of the action set played by the sequencer.

##### Remarks

In the following example, actionsetname is a variable set to the name of the action set that was last played. The example tests the actionsetname parameter passed and conditionally executes a script based on which action set has been played.

    Sub Sequencername_onplay(actionsetname)
    	If actionsetname="ActionSet1" then
    		Call Seq("ActionSet2").stop
    	Else
    		Call Seq("ActionSet1").stop
    	Endif
    End Sub

###

onseek Event

Sequencer Control

Called after the Seek method is invoked against a sequencer has completed changing the playback position. At this point, the specified script code is run.

VBScript Syntax
Sub object_ onseek (
actionsetname,
newtime
)
script
End Sub

JScript Syntax
<script language="javascript" for="object" event="onseek(
actionsetname,
newtime
) ">
<!--
script
//--><script>

##### Parameters

object
  Name of the sequencer.
actionsetname
  Specific action set from which the Seek method was invoked.
newtime
  New playback time to which the sequencer has been moved.

##### Remarks

You can use this event to determine where the sequencer playback has been moved and to set up conditional actions based on the sequencer's new position. However, you can't have an onseek event call a Seek method that seeks to a position within the same action set from which the onseek event originated.

    Sub Sequencername_onseek(actionsetname, time)
    	If actionsetname="ActionSet1" then
    		If time=10.000 then
    			Call Seq("ActionSet2").Play
    		Else
    			Call Seq("ActionSet1").Play
    		EndIf
    	EndIf
    End Sub

###

onstop Event

Sequencer Control

Called when the sequencer is stopped. At this point, the specified script code is run.

VBScript Syntax
Sub SequencerName_onstop(
actionsetname
)
script
End Sub

JScript Syntax
<script language="javascript" for="object" event="onstop(
actionsetname
) ">
<!--
script
//--><script>

##### Parameters

SequencerName
  Name of the stopped sequencer.
actionsetname
  Name of the action set stopped by the sequencer.

##### Remarks

In the following example, actionsetname is a variable set to the name of the action set that was last stopped. The example tests the actionsetname parameter and conditionally executes a script based on which action set has been stopped.

    Sub Sequencername_onstop(actionsetname)
    	If actionsetname="ActionSet1" then
    		Call Seq("ActionSet2").play
    	Else
    		Call Seq("ActionSet1").play
    	Endif
    End Sub

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.