BEFORE jumping in to coding and syntax, it is important to become familiar with the "Object-Oriented" structure on which today's languages rely.

OBJECT ORIENTED PROGRAMMING (OOP) is the prevailing method for programming applications today. While coding simple interactive Flash work does not require structure of this sort, it is extremely valuable when your programs become larger, and more difficult to deal with. The basic idea, is to group pieces of code that perform specific behaviours together, and have them structured in a way that more closely represents real-world objects.

First, some review of the basic concepts of programming:

Variable A name (identifier) representing the location of a piece of data in a computer program. Common variable types include integer numbers, floating-point numbers, booleans and strings
Method A set of instructions (lines of code) that can be executed using a method call.Methods are run independently and do not accept or return variables
Function A set of instructions (lines of code) that can be executed using a function call. A function is called by sending the function one or more variables, and returning a new value.
Object A set of variables with associated, localized methods and functions .
Class A prototype, or blueprint to be used when creating Objects.

 

 

Why do we use Object-Oriented Programming? The answer is that the process of creating Objects out of a Class is not a simple matter of duplicating a single Object. A common analogy is that of a vehicle, say a bicycle. The Class says that a bicycle must have two wheels, gears, pedals and handlebars. Then there is the process of "Constructing" the Object. In doing this, properties are defined such as wheel size and gear ratios. Now you have a bicycle. The bicycle is free to move around, based on the constraints of its design. OOP allows a programmer to quickly and easily build as many bicycles as needed, and they will all react based on their own wheel sizes, gear ratios and any external force that is applied to them. Using sequential programming techniques, the programmer would have to keep track of every single property of every single bicycle instead of defining the Class "Bicycle" to apply to as many objects as needed.

A pragmatic example can be found within the Flash interface. Your library holds Symbols, which are like Classes. By dragging a Symbol onto the Stage, you have "constructed" or "instantiated" the Class and created an Object. Each instance has its own properties, like _x, _y, _alpha, methods like stop() and functions like gotoAndStop(10) which can be accessed by using the Flash interface, or through Actionscript.

 


view source

This example generates 64 Objects from the Square Class. These Objects have their own position and speed properties, as well as methods to detect collision with the boundary, resulting in a reversal of their velocities.

 

Resources
Simple OOP Simple Motion Excellent practical tutorial for sequential coding versus Object-Oriented coding in Processing.
Object Usage Processing reference for use of Class and Object.
Objects Example Processing.org example of use of Class/Object
Actionscript 2.0 OOP Exhuastive resource for coding OOP in FlashMX 2004 using Actionscript 2.0 from Kirupa.com