9.5. Handling multiple moving objects

9.5.1. Generating multiple flying objects

One of the efficient ways to create and control multiple objects is to use an array structure. By using one variable name, an array can store a number of different things. It also allows you to manipulate them in a consistent manner. This section is dedicated to multiple moving objects and to showing you how to use an array to generate and control them on a Web page. For example, if you have a butterfly image bfly01.gif, you can display it at the (90, 240) top left position with the following XHTML statement:

   <img id="obj1" src="bfly01.gif" alt="pic" s
     style="position:absolute;top:90px;left:240px;width:32px;height:32px" />

If you have 5 red butterflies (bfly01.gif), ...

Get Practical Web Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.