ModifiableBehavior Class

Provides an asynchronous method of modifying behaviors, often in response to externally generated application events. It is instanced with the new operator, is given an initial behavior, and results in a new behavior for the caller to use. Here is an example:

//...Create a solid color image somewhere in the program.
//It will have a switchable color.
ModifiableBehavior sw = new ModifiableBehavior(red);
ColorBvr col = (ColorBvr)(sw.getBvr());
ImageBvr im = solidColorImage(col);

//...somewhere else in the program...
sw.switchTo(blue);

Anywhere that col was used will turn from red to blue. In this example, sw contains an untyped Behavior which the example explicitly casts to a ColorBvr. This is necessary because ColorBvr is the type provided as the input to the construction of sw. Calls to switchTo must carry arguments of the same run-time behavior type as the one with which sw was constructed. The replacement behavior begins as soon after the transition occurs as is possible.

ModifiableBehavior Methods

getBvr Extracts the Behavior component of the ModifiableBehavior object.
ModifiableBehavior Use the new operator to construct an instance of the ModifiableBehavior class.
switchTo When invoked, replaces the behavior generated by getBvr with the provided behavior.

getBvr

ModifiableBehavior Class

Extracts the Behavior component of the ModifiableBehavior object.

Syntax

public Behavior getBvr( );

Return Value

Returns the Behavior object.

Remarks

This behavior is subject to the switchTo invocations on the ModifiableBehavior object itself.

ModifiableBehavior

ModifiableBehavior Class

Use the new operator to construct an instance of the ModifiableBehavior class. Supply an initial behavior and a behavior context.

Syntax

public ModifiableBehavior( Behavior initialBvr );

Parameters

initialBvr
Initial behavior.

switchTo

ModifiableBehavior Class

When invoked, replaces the behavior generated by getBvr with the provided behavior.

Syntax

public void switchTo( Behavior newBvr );

Parameters

newBvr
Behavior that is begun once the switchTo method is invoked.

Remarks

Calls to this method must carry arguments of the same run-time behavior type as the one with which the ModifiableBehavior object was constructed. This is an immediate method, which means the new behavior is started when the transition occurs.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.