Counter
The Counter widget listens for a peak value from its input, and each time this value is received, it changes the counter output by the increment. For example, every time a button is pushed, the value of DigitalIn transitions from 0 to 1023. The Counter widget can monitor this and increment by 1 each button press. If the “min” is set to 0, and “max” is set to 1, the Counter output will toggle between 1 and 0 each time the button is pressed, creating an on/off button out of a momentary button. Another example would use the Counter to advance through a series of frames in a Flash MovieClip, where “min” is set to the first frame, and “max” is set to the last frame. In this case, the ClipControl widget would use the Counter widget as its input by specifying the instance name of the Counter.
On Screen Features
- THRESHOLD: The threshold for incrementing the Counter output. If the most recent input value is greater than or equal to THRESHOLD after being less than THRESHOLD, the output value will be incremented by INCREMENT.
- INCREMENT: The amount the Counter output will be incremented each time THRESHOLD is reached. Increment can be either positive or negative (for decreasing the value of the output each time).
- MIN: The lowest value of the Counter output. If the INCREMENT value is negative, and the output is at MIN, the next time the THRESHOLD is received, the output will be MAX.
- MAX: The highest value of the Counter output. If the THRESHOLD is reached when the output is at MAX, the next value of output will be MIN.
Parameters
- INVISIBLE: if set to “yes”, the widget will disappear when the Flash movie is run
- INPUT SOURCE the instance name of the source the widget listens to, e.g AnalogIn or DigitalIn. Note: Counter can be used as an input to other widgets. Give the Counter widget an instance name and use this as the INPUT SOURCE for the widget using Counter as its input.
Code Interface
The Counter code interface enables the user to reset or change the count from code.
In all of the below examples, the code assumes that there is a Counter widget on the stage with the instance name “myCounter”.
setCount(count:Number)
Sets the current count as visible in the OUT field. Sends this new value to the output of the Counter widget.
myCounter.setCount(0);
Last modified April 7th, 2011

