In the applet below, the user can, again, create new dots by clicking on the board and delete dots by clicking on them. Additionally, the user can choose a color of subsequent dots by clicking on BLUE or RED buttons. The RED OUT and BLUE OUT buttons delete all dots of the corresponding color. Each time anything changes, the fill is updated.
Download
Download the fla file for this example with complete, well-commented source code.
- Flash CS3 file names_part2.fla
The Challenges in Example 2
Additonal challenges in this more complex example are:
- Being able to tell, at any stage of the process, which dot is red and which is blue.
- Access the red (or blue) dots only to delete them and update the fill.
To accomplish that, we assign a unique name to each dot created. We use the new to AS3 'name' property of DisplayObject. The name contains the string 'red' or 'blue', depending on the color of the dot. Then we use getChildByName method to identify dots to be removed.
We discuss the code in more detail on page 4 of this tutorial. On the next page, we discuss the code for the simpler case in Example 1.










