In the Getting Mouse Events sample code, you learn how to get the mouse events and show the
names of the events. You may make the most of these events to trigger certain
functions you have learned in previous pages of sample code. In this example, you see how to
make a background fade in or fade out, in 2 seconds, by clicking the left mouse button
(clicking the middle or right mouse buttons does not bring any reaction to the
Please click on the player to observe the effect.
The player reacts to the mouse clicking event (left mouse button only) and
shows or hides the foreground image logo.
The ShowOrHide = !ShowOrHide; line inverts the variable
value from true to false or from false to true.
The player.showForeground line thus will show or hide the foreground image in 2 seconds in
order to create fade in or fade out effects.
Although the codes above merely assign the
ability to show or hide the foreground
according to the
left-mouse-clicking event, you are free to add different functions you have learned in the other
pages of sample code into these event cases so that these functions can be triggered
by certain mouse events.