The dispatcher will notify the handlers of the triggering
of the subscribed events. To simplify the thing, imagine a hypothetical button object, the dispatcher, that
has an onClick event (the on prefix is a widely used convention to identify the events easily). In the
code, the developer can associate a function, the handler, to the onClick ; the function is then executed
each time the button is effectively clicked.
The Flash API provides a great number of events to cover the most common situations. The basics of
events management is explained in the following sections; refer to the Flash documentation for further
information.
Events in Flash 6 to 8
The base event model in Flash before version 9 is quite simple. The objects that need to expose events
have functions starting with the on prefix. Those have by default an empty implementation; if they are
invoked, they simply do nothing. The developer subscribes to the events simply providing a definition
for such functions.
In the following example, a small green square is created with three event handlers; the first,
onMousePress , is triggered when the mouse is pressed over the square; the second, onRollOver , and
the third, onRollOut , are triggered respectively when the mouse enters the square area or leaves it.
Pages:
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642