2 Replies Latest reply on Apr 3, 2010 6:27 AM by sailwave

    derive new class from air.File


      Could some kind person show me how to derive a new class from air.File using javascript.  Everything I try seems to be wrong.  Essentially I need a new class called RegattaFile that has some extra properties and methods.


      When an object method to be the callback to a dispatcher - how do you do it?  When I try, the callback function gets called, but it's lost the 'this' context.


      I'm getting reallty confused.

        • 1. Re: derive new class from air.File
          Joe ... Ward Level 4

          Most of the runtime classes are final for performance reasons. You generally can't (as far as I know) extend hem in JavaScript using the prototype change.


          The this problem in callbacks and event handlers in JavaScript usually occurs because "this" is evaluated as the calling object rather than the class object. One way to solve the problem is to capture the this variable in another local variable in the class and use that variable in the callback or event handler. Something like:


          //in class definition

          var that = this;


          function callback()


               that.value = nnn; //instead of this.value


          1 person found this helpful
          • 2. Re: derive new class from air.File
            sailwave Level 1

            thanks joe - appreciated - ill give it a go...