This tutorial was created by James Hamblin of Shippensburg University. James is a friend of flashandmath.com. The applet below contains the well-known Lights Out game. Since the number of squares is generated randomly at runtime, the event listeners attached to the squares have to be created at runtime. The listeners are similar for each square but not identical.
Download the 'fla' file corresponding to the applet.
On the next page, James discusses in detail the code behind the applet.
Note: James Hamblin is an Associate Professor of Mathematics at the Shippensburg University, PA. You can find more of his Flash applets at http://webspace.ship.edu/jehamb/flash/.