When we modified the compiler to generate Actionscript 3, we made it generate actual method declarations for handlers, both for efficiency and also so you can reference other instance vars in the "implicit this" scope of the instance. So if we're making method declarations, we need a class to put them in. If you define any methods in an instance, or define any constraints on it, it magically builds an anonymous class for your instance.
This is defnitely an extra level of complexity for people if they look under the covers at what is being done, although in practice it's pretty much invisible to users. On Fri, May 7, 2010 at 4:16 PM, Raju Bitter < [email protected]> wrote: > Have a look at this code: > > <canvas width="100%" height="600" debug="true"> > > <class name="test1" extends="view"> > </class> > > <test1 x="100" y="100" width="100" height="100" bgcolor="#ff0000"> > <handler name="onclick" args="p"> > Debug.write(this); > Debug.write(parent); > </handler> > > <handler name="onclick" reference="b1" args="p"> > Debug.info("Event received by " + p); > Debug.write(this); > Debug.write(parent); > </handler> > </test1> > > <button id="b1" text="Click me" /> > > </canvas> > > When I click on the button, the onclick handler within test1 is called. But > "this" is an anonymous class extending test1. That's not very logical, is > it? I can imagine there was a good reason that you have to generate a > separate sprite object here, but it's very hard for programmers to > understand the underlying object structure. Is that the new way of dealing > with handlers? > > Thanks, > Raju > > -- Henry Minsky Software Architect [email protected]
