Articles Archive
Director Forums
Director Wiki
Job Board
Search
 
 Director Online WikiMain Page | About | Help | FAQ | Special pages | Log in | Printable version | Disclaimers

Object Oriented Programming

From Director Online Wiki

OOP in general

The idea behind OOP is that you try to separate code-elements from another, so that you can treat them separately without caring about the other. You can compare it to the idea of a microwave - you have an interface to control the microwave, and you get your hot meal from it. You don't need to care how it exactly works - and you can't (or at least shouldn't) change the internal electronics. In code you create such elements, that have certain access-interfaces - so that you can use them without breaking the internal code. These code elements are mostly called classes - or in Director "parentScripts" and "behaviours".

Good sources for deeper information:

[[1] (http://en.wikipedia.org/wiki/Object_oriented_programming)] [[2] (http://c2.com/cgi/wiki?ObjectOrientedProgramming)]

Basic OOP in Director

Director kind of pushes you to use the basics of OOP, because sprites are controlled by behaviours. These are scripts that should only control the sprite they are attached to. Don't use one movieScript for all your code.

Also try to put recurring tasks into methods. This way you only need to change one method instead of searching though all your code for changes. Give your Methods descriptive names (verbs) that exactly tell what they are supposed to do.

Advanced OOP in Director

Keep in mind that the Director ScriptingLanguage?s are not a full fledged OOP languages. You will miss things like PrivateVariable?s and PrivateMethod?s.

You can use Single Inheritance: define ancestors for your scripts, so they inherit the properties and methods of their ancestor. (See Lingo Inheritance for details - don't trust the Director Documentation there).

Multiple Inheritance is not officially supported.

Retrieved from "http://www.director-online.com/dougwiki/index.php/Object_Oriented_Programming"

This page has been accessed 2090 times. This page was last modified 18:00, 9 Apr 2005.