Introduction

Flash is a lightweight cross-platform runtime for rich media, enterprise applications and mobile applications, as well as an integrated development environment. Flash can be programmed in ActionScript 1/2/3.

Thursday, July 31st, 2003 at 7:12 pm

With()

I just realized how faulty with() is in Flash. Well, I knew that it is faulty but I didn’t know that it has an affect on the super Object. Here’s an example:

SuperClass = function(){};
SuperClass.prototype.init = function(){
        trace(”SuperClass: init“);
}

SubClass = function(){};
SubClass.prototype = new SuperClass();
SubClass.prototype.init = function(){
        trace(”SubClass: init“);
        super.init();
}

myObj = new SubClass();
with(myObj){
        init();
}

The output is:
SubClass: init

and not like expected:
SubClass: init
SuperClass: init

If you replace the with call with the following code the script works properly:

myObj.init();