Question

Basically, I want to modify the constructor of the Object
class. Since every class extends Object, I hope whenever any
object of any class is instantiated, the modified function will
be called.

So I did this :

 Object.prototype.constructor = function (){
            trace("it was called;");
        };

and put a breakpoint on the trace statement.

But it didn't stop there.
The trace statement did not get executed also.

Any solutions/suggestions?

Was it helpful?

Solution 2

I don't think it's possible in AS-3, but it was in AS-2.

OTHER TIPS

In which context are you coding? If you're using the Flex Compiler MXMLC (default, if you're in FlashBuilder), than you could add the compiler option -es. This should make AS3 feel more like AS2 and JS and support the prototype chain inheritance.

-compiler.es alias -es

"use the ECMAScript edition 3 prototype based object model to allow dynamic overriding of prototype properties. In the prototype based object model built-in functions are implemented as dynamic properties of prototype objects. (advanced)"

I don't know, if this plays well with all the extensions Adobe added to the ECMA Script standard, like packages, namespaces and classes. But you could give it a try.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top