## DABehavior Class

All behaviors are potentially time-varying and/or reactive values such as colors, numbers and images. They can be used to construct animated objects. All behavior subclasses inherit the functions of this class.

Because all behaviors (animated objects) are potentially time-varying and/or reactive, their values can change as a function of time or as the result of user input. Time-varying behaviors are created by combining time-based default behaviors (such as LocalTime) with other behaviors. Reactive behaviors are created using the Until and UntilEx functions and by specifying input events, such as mouse clicks. Complex behaviors can be built by combining existing behaviors. The value of a complex behavior always depends on the values of the behaviors that comprise it.

When a behavior runs, its time-varying and reactive qualities are active. This means the user can experience any changes that occur in the behavior as time passes or events occur.

- DABehavior Functions
- DABehavior Subroutines
- Relevant Functions from the DAStatics Class

### DABehavior Functions

DurationAnim

Duration

GetClassName

Hook

Init

IsReady

Repeat

RepeatForever

RunOnce

SubstituteTime

####

DurationAnim

DABehavior Class

Creates an animation fragment by associating a local "stop time" with a behavior. The result is a new behavior that is the same as the original behavior for the length of the duration. Once the duration is over, the behavior is a snapshot of the behavior's state when the duration ended.

DurationAnim(
length
)

##### Parameters

length
  The DANumber object representing the length of time, in seconds, that the duration lasts. This must be an animated number.

##### Return Values

Returns the DABehavior object.

####

Duration

DABehavior Class

Same as DurationAnim except that length is a non-animated number (a double).

Duration(
length
)

####

GetClassName

DABehavior Class

Returns the name of an object's class.

behaviorObj.GetClassName( )

##### Return Values

Returns a String.

####

Hook

DABehavior Class

Allows a running behavior to be sampled.

behaviorObj.Hook(
notifier
)

##### Parameters

notifier
  The object that controls the sampling of the DABehavior.

##### Return Values

Returns a DABehavior object.

####

Init

DABehavior Class

Initializes an uninitialized object. Here is an example of how to create an uninitialized DAPoint2 object in VBScript:

    Set myPt = CreateObject("DirectAnimation.DAPoint2")

And here is how to create an uninitialized object in JScript:

    myPt = new ActiveXObject("DirectAnimation.DAPoint2");

To initialize the object in VBScript, use:

    myPt.Init(...)

The only difference in JScript is that it needs a semicolon at the end of the line. For example, consider the following JScript code:

    myPt.Init(m.Unitl(position, resetEvent,resetPosition);

The Init function can also be used on uninitialized arrays (UninitializedArray) and uninitialized DATuples (UninitializedTuple).

behaviorObj.Init(
behavior
)

####

IsReady

DABehavior Class

Determines if all the imports for the behavior have been downloaded. Only works when the behavior is, itself, an import. Otherwise returns E_NOTIMPL.

behaviorObj.IsReady(
bBlock
)

##### Parameters

bBlock
  A boolean which, if FALSE, indicates that IsReady should return immediately and, if TRUE, indicates that it should block until the behavior is ready.

##### Return Values

Returns a boolean which, if TRUE, means all the imports have been downloaded.

####

Repeat

DABehavior Class

Creates a behavior that repeats itself the number of times specified by repetitions.

behaviorObj.Repeat(
repetitions
)

##### Parameters

repetitions
  The number of times the behavior will repeat.

##### Return Values

Returns the DABehavior object.

####

RepeatForever

DABehavior Class

Creates a behavior that repeats infinitely.

behaviorObj.RepeatForever( )

##### Return Values

Returns the DABehavior object.

####

RunOnce

DABehavior Class

Used when applications must reference a running behavior once it starts running, but don't require the application to explicitly start that behavior.

behaviorObj.RunOnce( )

####

SubstituteTime

DABehavior Class

Creates a new behavior from an existing DABehavior and a DANumber. In the new behavior, the animated number replaces all occurrences of LocalTime in the original behavior. (This includes behaviors where LocalTime is implicit, such as imported movies. The function can be used even if LocalTime isn't explicitly in the code.) This allows behaviors to be, for example, time-scaled to run faster or slower, time-shifted to start at a different time, or frozen at a particular point in time.

behaviorObj.SubstituteTime(
a
)

##### Parameters

a
  The DANumber object that replaces LocalTime.

##### Return Values

Returns the DABehavior object.

### DABehavior Subroutines

SwitchTo

####

SwitchTo

DABehavior Class

Replaces one behavior with another. The inital behavior is set with the ModifiableBehavior function in the DAStatics class.

behaviorObj.SwitchTo(
newBehavior
)

##### Parameters

newBehavior
  The DABehavior object that will replace the initial behavior.

### Relevant Functions from the DAStatics Class

The following functions are defined in the DAStatics class and are most relevant to objects of type DABehavior.

lib.Cond(bool, a, b)

lib.ModifiableBehavior(initialBehavior)

lib.Sequence(a, b)

lib.Until(a, e, b)

lib.UntilEx(a, e)

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