• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part VII: Using Advanced Lingo > OBJECT-ORIENTED PROGRAMMING

Chapter 23. OBJECT-ORIENTED PROGRAMMING

IN THIS CHAPTER

What is an Object?

Reasons to Use Objects

Creating an Object in Lingo

Creating Object Properties

Using OOP

Using Ancestors

Source movies for this chapter can be found on the CD-ROM in the “Book Movies” folder under folder 23.

Object-oriented programming, also known as OOP, is a term that might scare some nonprogrammers. It sounds mysterious and complex. In reality, it is what you have been doing all along in Director. OOP is simply programming that marries code to data. A behavior, attached to a sprite, is OOP. The code is the Lingo in the behavior, and the data is the properties of the sprite: the member, location, and custom properties of the behavior.

A code object is a self-contained unit of code in memory that keeps track of its own internal data. Code objects have internal variables called properties and they respond to messages just as behaviors do. But unlike behaviors, you can't just drop them into the Score to use them.


OOP enables you to write one piece of code, and then reuse that code for different objects. In Director, those objects are usually sprites, but they don't have to be. An object can be just an invisible set of data, such as an entry in a database or an enemy ship in a game.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint