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.

video

What Is ActionScript 3.0 ?


ActionScript 3.0 was introduced in 2006 with the release of Flex 2. Flex enables developersto build applications that require the Flash Player, just like Flash does. However,Flash offers a more visual interface for developing applications, one better suited forgame development.ActionScript was introduced in 1996 with the release of Flash 4. It wasn’t called ActionScript yet, and you couldn’t even type your code. Instead, you chose statementsfrom a series of drop-down menus. Flash 5 in 2000 improved on that greatly with the formal introduction of ActionScript1.0. This scripting language contained all the bells and whistles of other web-baseddevelopment languages, such as Macromedia Director’s Lingo, and Sun’s Java. But, itcame up severely short in speed and power.Flash MX 2004, also known as Flash 7, brought us ActionScript 2.0, a much morepowerful version of the language that made it easier to create object-oriented programs.It was much closer to ECMA Script, a standard for programming languages developedby the European Computer Manufacturers Association. JavaScript, the programminglanguage used in browsers, is also based on ECMA Script.



ActionScript 3.0 is the culmination of years of development. As each version of Flash came out, developers pushed it to the limit. The next version took into account what developers were using Flash for, and what the weaknesses of the current version of ActionScript were.
Now we have an excellent development environment for 2D game development. You’ll find that one of its main strengths is being able to get games up and running with only a small amount of code.

Foreword: ActionScript and Flash Animation


There is a deepening chasm in the Flash world between those who understand and use ActionScriptin their work and those who don’t. We sometimes erroneously call this the difference between“designers” and “developers.” The assumption is that “designers” do not understand code and“developers” do not understand design. This is, at best, a convenient oversimplification.The labels “designer” and “developer” may have sufficed in the early days of the Web when we wereall still trying to make sense of this new and exciting medium. More than a decade since, we havediscovered that the medium is not entirely new and that it does not exist in a vacuum, separatefrom all that came before it and all that exists alongside it.

Today, the “designer”(Flash Animation) and “developer” labels do not tell you much about what a person is or what aperson does. And yet they are frequently used to describe both. As a description of job function, these labels are woefully inadequate in detail. What type of designwork do you do? What is your function on the team? Do you do graphic design, or motion graphicsdesign, or information design (architecture), or object design (modeling)? By lumping graphicdesigners, information architects, animators, and illustrators under the huge catch-all category of“designer,” you strip that label of any meaning whatsoever. The role of the “developer”—at least in a Flash context—appears to be somewhat better defined. You can assume to some degree of accuracy that the person’s job involves building user interfacesand, more than likely, programming.Where these titles lack the necessary granularity in describing job function, one thing is certain: They are overly restrictive when it comes to describing who a person is. “I am a designer,” for example,is often used to justify time not spent learning to program. Similarly, “I can’t draw a straightline” is an oft-used excuse by “developers” to rationalize a lack of invested time in learning thebasics of graphic, motion graphics, and user interface design. (Contrary to popular belief, many ofthe best graphic and motion graphics designers in the world couldn’t draw a very impressive straightline either if given an easel and brush; similarly, some of the most talented artists I know couldn’tdesign a passable user interface layout to save their lives.) No, at the personal level, you should accept no less than the title of “artist” and aspire to earn theright to carry the title. And earning this right is influenced not so much by your accomplishments asby your approach: a relentless pursuit of perfection, where the journey is the destination. Like it or not, we are the artists of our era, and this crazy and wonderful conglomerate of digitalmedia are our easels, palettes, and brushes. We can create beautiful things, thought-provokingthings, things that can make a difference. And we can potentially reach more people in more waysthan has ever been possible in the past.