Hi,
I believe, that I've found a bug in the Flash 8 compiler.
Just for the facts: I have Flash 8 Professional (English edition) for
Windows XP - no other version number, as far as I can see.
The bug is, that the compiler will result in a missing pop-operation
thus leaving an extra item on the stack when extending movieclip and in
the constructor of the subclass calling a function of the movieclip
class. The special extension-function will have a missing pop-operation
when the super-function is called without adding "this." or "super." to
the function call.
The simplest case is a FLA file only containing:
var sc:SubClass = new SubClass();
trace(sc instanceof SubClass);
And SubClass only containing:
class SubClass extends MovieClip {
public function SubClass() {
play();
}
}
The trace will be false in the above, but when adding "this." or
"super." to the play-invocation, the trace will be true.
When decompiled with Flasm 1.6 the only difference between a SWF with
"this." and without is, that with "this." an extra pop()-operation is
added. And this pop-operation should be there, as it will properly
remove the "something" from the stack. (both FLM-files added for
reference in below-mentioned ZIP)
The above is just a simple example, it is not actually occuring as we
all know, that you cannot instantiate movieclips through the
constructor. But you can instantiate movieclips by adding them to a
movieclip in the library and attach this movieclip. Thus we can add an
extra class Attacher:
class Attacher {
public function Attacher() {
_root.attachMovie("SubClass", "sub", 1);
}
}
And in the FLA file we create a movieclip in the library with the AS2
class and identifier "SubClass". We change the frame actionscript to:
var attacher:Attacher = new Attacher();
trace(attacher instanceof Attacher);
Now, attacher is _not_ an instance of class Attacher. It is actually
undefined. And _that_ is a bug!
It only occurs when extending movieclip (or maybe also Button or
TextField, haven't tried those), and only when the reference to the
super-function is in the constructor of the subclass. Haven't tried Flash 7.
I've added all the files needed to reproduce (and I've reproduced at
other computers with Flash 8) to a zip, and it can be downloaded at:
http://actionscript.dk/downloads/bughunt.zip
Feel free to comment.
This bug report will be submitted to Macromedia after the sending of
this mail.
--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders