The ParameterListener Object
The ParameterListener object listens for changes to the value of a named Parameter. When a change occurs, a user-specified function will be called. The object also provides methods for getting and setting the value of the observed Parameter.
ParameterListener Constructor
var pl = new ParameterListener(parameter_name, function);
The js object running the script. Parameter names are global to a patcher hierarchy, so there's no need to know the Patcher or Maxobj for the Parameter.
argument is string specifying a Parameter in the patcher hierarchy of theThe ParameterListenerData object.
argument specifes the function you want to execute. The function should have a single argument, which is aExample:
function valuechanged(data) {
post("parameter value changed: " + data.name + "\n")
post("new value: " + data.value + "\n")
}
l = new ParameterListener("myParameter", valuechanged)
For convenience, the ParameterListener object is a property of the ParameterListenerData argument to the function. To access the ParameterListener from within its function:
data.listener
ParameterListener Properties
name [string]
The Parameter to observe.
silent [int]
Never execute the callback function in response to calling
from this ParameterListener.ParameterListener Methods
getvalue
Report the value of the Parameter. List values are reported in a JS Array object.
setvalue
Set the value of the Parameter.
setvalue_silent
Set the value of the Parameter, without executing the callback function (also see the
property).ParameterListenerData
The ParameterListenerData object is the argument to your ParameterListener's function
ParameterListenerData Properties
listener [ParameterListener]
The ParameterListener which called the function.
name [string]
The name of the Parameter which changed.
value [value or Array]
The current value of the Parameter. List values are represented by a JS Array object.
See Also
Name | Description |
---|---|
JavaScript Usage | JavaScript Usage |