Originally posted by Ironclaw
Still cant understand how:

Code:
Circle.prototype.area = function() {
	return Math.PI*this.radius*this.radius;
};
function Circle(radius) {
	this.radius = radius;
}
var myCircle = new Circle(5);
var myCircleArea = myCircle.area();
trace(myCircle.area());
OOP would help me.

well, this is as i would tell it...

Circle is the class

PHP Code:
function Circle(radius) {
    
this.radius radius;

this would be the class constructor, a function which constructs a new instance of the circle class

PHP Code:
Circle.prototype.area = function() {
    return 
Math.PI*this.radius*this.radius;
}; 
this is a prototype function of the circle class, all instances (all circles) will have access to this function.

An instance of the circle class is constructed with:
PHP Code:
var myCircle = new Circle(5); 
the circle class constructor asks for a radius of all its new instances, in this case myCircle has a radius of 5

as myCircle is an instance of the circle class it has access to the Circle prototype function...
PHP Code:
var myCircleArea myCircle.area(); 

hope this helps...