Chapter 6. OOP

IN THIS CHAPTER

Classes

Inheritance

Composition

Encapsulation

Polymorphism

Navigation Bar Revisited

What’s Next?

Object-oriented programming (OOP) is an approach to coding that uses classes to create individual objects and control how those objects interrelate. It’s sometimes described as a problem-solving technique—a programming style that addresses issues that procedural programming (which is also referred to as timeline programming in Flash Professional) can’t handle well. It’s a way of organizing your code into small, specific, easily digestible chunks to make project or application development more manageable. These objects are typically designed to be as self-contained as possible, but are also usually designed to play well with other objects.

Whether you know it or not, you’ve been flirting with object-oriented programming for some time now, You’ve been creating objects from classes, calling methods, getting and setting property values, and so on. Each time you create a movie clip with ActionScript, for example, you’re creating an object by instantiating the MovieClip class. But although you may be using objects fluently while coding in the timeline, this is only the tip of the OOP iceberg. To really embrace OOP, you need to write your own custom classes, guided by a few basic object-oriented principles that we’ll discuss in this chapter. For our discussions, we’ll further define OOP as using classes primarily, if not entirely, rather than simply using objects in procedural ...

Get Learning ActionScript 3.0, 2nd Edition 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.