piątek, 4 lipca 2008

Action Script: Objects and Lists

We’ve already discussed display objects. They are essentially any graphic element. Themost versatile of all display objects is the movie clip, which is a full graphic elementthat includes any number of other display objects, plus a timeline for animation. A simpler version of the movie clip is a sprite. A sprite is essentially a movie clip withonly one frame. When we create display objects from scratch in ActionScript, we’ll usuallybe making sprites. They are naturally more efficient than movie clips because theydon’t have the overhead of multiple frames of animation.Other display objects include things such as text fields, bitmaps, and video.Some display objects, movie clips, and sprites can have other display objects in them.For instance, you can have a sprite that contains several other sprites, as well as sometext fields and bitmaps.Nesting display objects provides you a way to organize your graphic elements. Forinstance, you could create a single game sprite to hold all the game elements you createwith ActionScript. Then, you could have a background sprite inside of it that containsseveral background sprite elements. A game pieces sprite could sit on top of that andcontain moveable game pieces.Because movie clips and sprites can contain multiple objects, they will each maintain alist of these items to determine the order in which they are displayed. This is called adisplay list. We can modify this display list to place objects in front of or in back ofother objects.

Brak komentarzy: