This tutorial is to get start learning basics fundamental concepts of ActionScript 3 programming, so lets start!
Object-oriented programming (OOP): is a programming paradigm that uses objects and Classes. Data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance.
Classes: Defines the abstract characteristics of a thing (object), in other words is a blueprint or factory that describes the nature of something. For example, the class "Car" will share characteristics will all cars, color, size, weight and different behaviors like speed.
Object: Is a pattern of a class. The class Car defines the characteristics and behaviors of a Car. The class "Mercedes" will have some specific style, color, speed, etc.
Instance: Is a blueprint of a object. The object consists of state and the behaviour that's defined in the object's class.
Methods: Actions and abilities of the object. Functions is classes are called methods.
Attributes: is the object data. Gives the state of the object
public class Car {
//private attribute, only can be accessed within the class
private var color:String;
//public attribute, can be accessed inside and outside of the class
public var size:int;
//Constructor of the class
public function Car(color:String, size:int) {
this.color = color;
this.size = size;
}
//public method, can be accessed inside and outside of the class
public function setColor(color:String):void{
this.color = color;
}
//private method, only can be accessed within the class
private function getSize():int{
return this.size;
}
}
//Instances of the object "Car"
car1 = new Car("blue", "200");
car2 = new Car("red", "500");
car1.setColor("yellow");
//throws an error: can't be outside of the class
car2.setSize("yellow");

Post new comment