O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Objects of Mystery

Now that some of the mystery has been dispelled about Behaviors, let’s discuss their cousins, parent scripts. I’ll show you why, when, and how to use Object-Oriented Programming (OOP). Once you are introduced to the concepts, I’ll then cover the terminology in more detail (refer also to the Glossary). Finally, I’ll cover some practical examples. When you finish this chapter you’ll realize that the “Great and Powerful Oz” is just some guy behind a curtain. So take a deep breath, repeat after me (“Parent scripts, child objects and Behaviors, oh my!”), and soon you’ll be more at home with OOP than Dorothy was in Kansas.

For a comparison of object-oriented Lingo with C++, refer to Table 4-1 in Chapter 4, and see the downloadable Chapter 20, Lingo for C Programmers. Read Chapter 12, Parent Scripts and Child Objects, in Macromedia’s Learning Director manual for another perspective on object-oriented programming. Refer also to the Simple Child Object and Multiple Child Objects Show Me demo movies in the online Help.

A Procedural Stopwatch

Typical Lingo scripting is procedural because you create procedures (functions or handlers) to perform a particular task. For example, the average() function might average two numbers.

Example 12-4. A Trivial Procedural Example

on average a, b
   return (a+b)/2.0
end

If a script calls a procedure, the only communication between them is via the value returned by the function to caller.

Tip

A function is like a one-night stand. It has a fleeting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required