Author: steve happ | Email
Website : www.video-animation.com
Advertisement
Classes
(As 2.0 only)
A class is a user-defined datatype, an aggregate of named data elements, and a set of operations to manipulate that data.
A class definition consists of two parts:
- The class head - composed of the keyword class and a name
- the class body - enclosed by braces, contains the member definitions
A class name represents a new data type .
e.g.
class Dog{
// data members
var name:String;
var age:Number;
// class method
function setAge(age1:Number){
age = age1;
}
}
Constructors allow us to create an instance of a class . e.g.
var rusty:Dog = new Dog();
// the dot operator (".")
// allows us to access members and methods of that class.
rusty.setAge(7);
rusty.name = "Rusty";
We hope the information helped you. If you have any questions
or comments, please don't hesitate to post them on the
Forums section
Submit your Tutorial at Click Here