## Static Methods Relevant to Behavior Objects

###

cond

Statics Class

Creates a new behavior from the BooleanBvr and two other behaviors. The value of the new behavior, at any point in time, is one of those two behaviors. Which of the behaviors chosen depends on the value of the BooleanBvr. Here is an example:

    //Create a new behavior, y, which is either 1.0 if x > 1.0, or another behavior, x
    	NumberBvr y = (NumberBvr)cond(gte(x, toBvr(1.0)), toBvr(1.0), x);

public static Behavior cond(
BooleanBvr bool,
Behavior a,
Behavior b
);

##### Parameters

bool
  The BooleanBvr object that determines which of the two behaviors will become the value of the new behavior.
a
  The first of the two possible values the new behavior can assume.
b
  The second of the two possible values the new behavior can assume.

##### Return Values

Returns the Behavior object.

###

sequence

Statics Class

Creates a new behavior that is the sum of the two Behavior parameters. In other words, the two behaviors are concatenated, according to their order in the parameter list. Once the duration is over, the behavior becomes a snapshot of the second behavior. An exception is when the first behavior is of infinite duration. In this case, the returned behavior is always the infinite behavior, no matter what the second behavior is.

public static Behavior sequence(
Behavior a,
Behavior b
);

##### Parameters

a
  The first behavior in the sequence.
b
  The second behavior in the sequence.

##### Return Values

Returns the Behavior object.

##### Remarks

Notice that, in contrast to compose, which first apply the right-hand argument and then the left, sequence first applies the left-hand argument and then the right.

###

until

Statics Class

Creates a behavior that changes when a given event occurs. Up to and including the time the event occurs, the behavior is the same as a. After the event e occurs, the behavior changes to be the same as b. Because until takes behaviors and returns a behavior, it can be nested. Here are some examples:

    //The ColorBvr col is initially red
    //It turns blue when the left mouse button is pressed
    ColorBvr c = (ColorBvr)until(red, leftButtonDown, blue);

    //Example of nested behaviors
    //The behavior is initially red
    //It turns blue when the left mouse button is pressed
    //And turns green when it is pressed again
    ColorBvr c = (ColorBvr)until(red, leftButtonDown,
    			until(blue, leftButtonDown, green));

public static Behavior until(
Behavior a,
DXMEvent e,
Behavior b
);

##### Parameters

a
  The Behavior object that the behavior represents initially.
e
  A DXMEvent object specifying the event.
b
  The Behavior object that the behavior represents after the event.

##### Return Values

Returns the Behavior object.

###

untilEx

Statics Class

Creates a Behavior that changes upon a given event. Initially, the behavior is the same as a. When event e occurs, the behavior changes to the behavior returned by the event. This means that only DXMEvents that return a Behavior can be used. These events can be constructed with attachData, notifyEvent, and snapshotEvent.

public static Behavior untilEx(
Behavior a,
DXMEvent e
);

##### Parameters

a
  The Behavior object that the behavior represents initially.
e
  The DXMEvent object that triggers the switch and returns the new behavior.

##### Return Values

Returns the Behavior object caused by the event e.

###

untilNotify

Statics Class

Creates a behavior that changes upon a given event. Initially, the behavior is the same as a. When event e occurs, the behavior changes to the behavior returned by the event notifier notifier.

public static Behavior untilNotify(
Behavior a,
DXMEvent e,
UntilNotifier notifier
);

##### Parameters

a
  The Behavior object that the behavior represents initially.
e
  A DXMEvent object specifying the event.
b
  The UntilNotifier object. The notify method of this object, called on the given event, returns the new behavior.

##### Return Values

Returns the Behavior object.

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