[subclass, superclass] → []
0x69
2 → 0
7
ActionExtends implements the ActionScript extends keyword. ActionExtends creates an inheritance relationship between two classes, called the subclass and the superclass.
SWF 7 adds ActionExtends to the file format to avoid spurious calls to the superclass constructor function (which would occur when inheritance was established under ActionScript 1.0). Consider the following code:
Subclass.prototype = new Superclass();
Before the existence of ActionExtends, this code would result in a spurious call to the Superclass superconstructor function. Now, ActionExtends is generated by the ActionScript compiler when the code class A extends B is encountered, to set up the inheritance relationship between A and B.
Field | Type | Comment |
---|---|---|
ActionCastOp | ACTIONRECORDHEADER | ActionCode = 0x69 |
ActionExtends does the following:
Pops the ScriptObject superclass constructor off the stack.
Pops the ScriptObject subclass constructor off the stack.
Creates a new ScriptObject.
Sets the new ScriptObject’s proto property to the superclass’ prototype property.
Sets the new ScriptObject’s constructor property to the superclass.
Sets the subclass’ prototype property to the new ScriptObject. These steps are the equivalent to the following ActionScript:
Subclass.prototype = new Object();
Subclass.prototype. proto = Superclass.prototype;
Subclass.prototype. constructor = Superclass;