AS 2.0 Classes

Out of context: Reply #9

  • Started
  • Last post
  • 11 Responses
  • caseyc0

    Know that AS2 is just a friendlier way of writing AS1. When you publish to swf the flash compiler goes through all the as2 and the resulting bytecode is just as1, old school prototype stuff.

    Basically what happens is that you can write in AS2:

    myVar

    Which is then converted in the swf to:

    this.myVar

    And the compiler doesnt touch your onRelease function so it is just looking for "myVar" when in reailty it needs "this._parent.myVar" to work.

    This is what things like mx.utils.Delegate are for, but if you dont want to use that the shortcut looks something like:

    var self = this;
    myButton.onRelease = function() {
    trace(self.myVar);
    }

    Cheers,

View thread