Joeri van Oostveen wrote:
> I'm having this (weird) problem:
>
> the doSomething() gets called 3 times!
> First time the B version, which calls the A function
(2nd one).
> Next, the A function is called again... which should
not be so!!! :(
It's a rather annoying but poorly documented bug that's
been around for
quite a while--at least since since Flash Player 6 if I'm
not mistaken.
If you search through the ChattyFig archives, you can find
some of the
past discussions here:
http://chattyfig.figleaf.com/piperma
il/flashcoders/2003-February/064363.html
http://chattyfig.figleaf.com/piperma
il/flashcoders/2004-November/126203.html
In addition to this bug, the super pointer has traditionally
been quite
problematic and buggy, particularly in atypical usages such
as
referencing a method other than the currently overridden one
from the
superclass, or within a with block.
In your case, the simplest solution would be to make sure
that you
override the afflicted method in each class in your
inheritance chain,
although this can get rather ugly very quickly, particularly
with large
codebases.
I actually ran into this exact same bug myself a couple of
weeks ago
while hacking together an AOP-based run-time profiler for
ActionScript
2.0 and got myself quite confused for a while until I hit up
a few
friends of mine whom helpfully refreshed my memory.
At that time, my friend and co-worker Sean Christmann
recommended the
following fix from a previous project of his:
<code>
_global.superFix = function(curSuper) {
// arguments.callee is this function object
// set the super passed in so we can use it in
__resolve
arguments.callee.__super = curSuper
arguments.callee.__caller = arguments.caller;
// return ourselves so the method gets called on us
return arguments.callee;
}
// Now, instead of calling super.myMethod(), do the
following:
superFix(super).myMethod();
</code>
Jim
_______________________________________________
Flashcoders chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcode
rs
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om
|