Behavior in Anark Studio 2.5

Represents a script behavior that can be attached to objects.

Inherits from:

Instance Properties

name type description
active Boolean Should this asset be drawn? [from Asset]
behaviors Collection (read only) All Behavior objects attached under this asset. [from Asset]
constructor Object A reference to the constructor class for the current object instance. [from Object]
context TimeContext (read only) The asset's local TimeContext object. [from Asset]
contextType Number Type of the TimeContext for this asset. [from Asset]
endLifeTime Number Ending time of the asset. [from Asset]
id Number (read only) Unique ID for the asset. [from Asset]
mouseEvents Boolean Does the object to which this behavior is attached respond to mouse events?
music Collection (read only) All Music objects attached under this asset. [from Asset]
name String User-defined name for the asset. [from Asset]
parent Object (read only) Parent object of this asset. [from Asset]
prototype Object The prototype for a class. [from Object]
sounds Collection (read only) All Sounds objects attached under this asset. [from Asset]
startLifeTime Number Starting time of the asset. [from Asset]
type String (read only) Type of the asset. [from Asset]

Instance Methods

name returns description
attach(assetObject) (none) Attach the argument underneath the asset. [from Asset]
copy() Asset Create a copy of the asset. [from Asset]
detach(assetObject) (none) Remove an asset from this asset. [from Asset]
hasOwnProperty(propertyOrMethodName) Boolean Determines if the object/instance itself has the named property or method. [from Object]
isPrototypeOf(instanceToTest) Boolean Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object]
propertyIsEnumerable(propertyOrMethodName) Boolean Determines if the object/instance itself has a property or method of the supplied name which will appear in a for (prop in obj) enumeration. [from Object]
toLocaleString() String For most objects, the same as toString() unless explicitly overridden. [from Object]
toString() String Returns a string representation of the object. [from Object]
valueOf() String Returns the internal this value of the object. [from Object]

Description

A Behavior object is a type of Asset and represents a collection of JavaScript statements that control the behavior of objects in a presentation. A behavior can be created using the Anark Studio interface, or it can be imported into Anark Studio from a text file with a .bvs extension. Behaviors may be attached to any object in the scene.

New behavior instances can be created from a behavior asset in the Anark Studio Library. Behaviors cannot be created using the scripting constructor because there would be no way to assign information to the behavior.

Library asset constructor syntax

var theBehavior = new Behavior( "library://libraryAssetName" [, objectToAttachTo] );
libraryAssetName
required — A String with the name of the asset in the Anark Studio Library from which to create this object.
objectToAttachTo
optional — The String name of the object to which the behavior will be attached.

Behavior Examples

function onAttach( )  
{  
	// Set the parent object to receive mouse events.  
	this.mouseEvents = true;  

	// Create a handle for this behavior.  
	this.mouseDrag = mouseDrag;  
}  
…
// From a different behavior, call the mouseDrag function.  
scene.DragDrop.mouseDrag( );