Archive for July, 2011

Actionscript 3.0 programming with classes and objects July 25th, 2011

admin

Programming using classes is essential to take advantage of the full power of actionScript 3.0. By using classes, you participate in object-oriented programming, a versatile way to think about and structure code. Objects are high-level building blocks, and classes are the constructs which define them. In this article you will learn what constitutes a class, how classes relate to objects and other language constructs, and how write a class in ActionScript 3.0

Classes in real world

To program using classes you must understand what classes are. Classes per-form multiple roles in object-oriented programming, and there are many ways to think about them. Classes often work best, and are easiest to think about, when they represent objects in the real world. You can, for example, create a class to represent a bicycle. That bicycle can have a color, a size , and two tires. You can pedal it, brake it, switch gears, and ring the bell. The bicycle has relationships with other real-world objects: your feet, the road surface, occasionally a bike pump. If we model bicycle as a class we represent all of these, and carefully design it to interact with the other objects in the right way.

Object

Object can have slightly different meanings in different contexts. An Objects is the basic unit of objects oriented programming. It is self contained thing that contains data and operations. Every objects is defined by a class. For example a bicycle object would be defined by the class Bicycle.

Class

A class is a blueprint for an object. It defines the object in full: the data and operations of that object. You write classes before you run your program, and when your program is running, they are set in stone. Classes contain the code you write. When your program runs, it’s an orchestrated production of objects, and that productions is directed by the code in the classes.

Instance

An instance is a specific object created from a specific class. It may be used by itself or with the name of  the class to specify the type of  the instance, as in “an instance of the FuzzyLobster class”. Instances are unique.


Continue reading...