Skip to content

Commit b26681b

Browse files
chore: Add comments explaining why we skip display object initializer calls
1 parent 00fb87e commit b26681b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

core/src/display_object/morph_shape.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
111111
if self.movie().is_action_script_3() && matches!(self.object2(), Avm2Value::Null) {
112112
let class = context.avm2.classes().morphshape;
113113
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), class);
114+
// We don't need to call the initializer method, as AVM2 can't link
115+
// a custom class to a MorphShape, and the initializer method for
116+
// MorphShape itself is a no-op
114117
self.set_object2(context, object.into());
115118

116119
self.on_construction_complete(context);

core/src/display_object/stage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ impl<'gc> TDisplayObject<'gc> for Stage<'gc> {
780780

781781
// TODO: Replace this when we have a convenience method for constructing AVM2 native objects.
782782
// TODO: We should only do this if the movie is actually an AVM2 movie.
783-
// This is necessary for EventDispatcher super-constructor to run.
783+
// This is necessary for DisplayObject and EventDispatcher super-constructors to run.
784784
let global_domain = context.avm2.stage_domain();
785785
let mut activation = Avm2Activation::from_domain(context, global_domain);
786786
let avm2_stage = Avm2StageObject::for_display_object_childless(

core/src/display_object/text.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
264264
if self.movie().is_action_script_3() {
265265
let statictext = context.avm2.classes().statictext;
266266
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), statictext);
267+
// We don't need to call the initializer method, as AVM2 can't link
268+
// a custom class to a StaticText, and the initializer method for
269+
// StaticText itself is a no-op
267270
self.set_object2(context, object.into());
268271

269272
self.on_construction_complete(context);

core/src/display_object/video.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> {
443443
let video_constr = context.avm2.classes().video;
444444
let object =
445445
Avm2StageObject::for_display_object(context.gc(), self.into(), video_constr);
446+
// We don't need to call the initializer method, as AVM2 can't link
447+
// a custom class to a Video, and the initializer method for Video
448+
// itself only sets the size of the Video- the Video already has the
449+
// correct size at this point.
446450

447451
self.set_object2(context, object.into());
448452

0 commit comments

Comments
 (0)