Home Contact

[January 13, 2008]

Advanced Users May Choose

Filed under: ActionScript — @ 7:33 pm

Can anybody show me a use case for the following?

(Flex language manual, Object.constructor)

Advanced users may choose to use the function keyword instead of the class keyword to define a Function object that can be used as a template for creating objects. Such a function is called a constructor function because you can use it in conjunction with the new operator to create objects. If you use the function keyword to create a constructor function, its prototype object is assigned a property named constructor that holds a reference to the constructor function. If you then use the constructor function to create an object, the object inherits the constructor property from the constructor function’s prototype object. For example, the following code creates a new constructor function, f, and an object named myF:

function f() {}
trace(f.prototype.constructor); // function Function() {}
trace(f.prototype.constructor == f); // true
var myF = new f();
trace(myF.constructor == f); // true

UPDATE: I’ve looked into this and I have some answers to my own question:
Dynamic Programming in AS3


Contents copyright © Alan Shaw 2005-2008

25 queries. 0.255 seconds. Powered by WordPress version 2.5.1