|
December 25, 1999 Returning Events from Behaviors Tips: December 1999
Yehuda Shiran, Ph.D.
|
|
We have covered in previous tips how to pass objects (December 24, 1999) and data (December 23, 1999) to a Behavior. But a Behavior not only accepts data -- it also generates events according to your specifications. In our Blinking Soccer Ball example from Column 22, DHTML Behaviors, we define an event called onFifthBlink, which signals the fifth blink of the soccer image. Behavior's events are defined in the scriptlet's interface section, in the Behavior type of IMPLEMENTS tags:
The generation of the event inside the scriptlet's implementation section is accomplished via the
Notice that we count to 10 instead of 5, because each blink consists of two visibility changes. Also, we reset the counter variable, to allow the event to be fired after every five blinks, not necessarily the first five.
The fired events are associated with the DHTML element from which the
People who read this tip also read these tips: Look for similar tips by subject: |