Skip to content

Commit f9ab908

Browse files
core/avm2: Construct StaticText aka Text DisplayObject at the correct time
1 parent 283a7cc commit f9ab908

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

core/src/display_object/text.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
255255
false
256256
}
257257

258+
fn construct_frame(self, context: &mut UpdateContext<'gc>) {
259+
if self.movie().is_action_script_3() && self.object2().is_none() {
260+
let statictext = context.avm2.classes().statictext;
261+
262+
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), statictext);
263+
// We don't need to call the initializer method, as AVM2 can't link
264+
// a custom class to a StaticText, and the initializer method for
265+
// StaticText itself is a no-op
266+
self.set_object2(context, object);
267+
268+
self.on_construction_complete(context);
269+
}
270+
}
271+
258272
fn post_instantiation(
259273
self,
260274
context: &mut UpdateContext<'gc>,
@@ -264,15 +278,6 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
264278
) {
265279
if self.movie().is_action_script_3() {
266280
self.set_default_instance_name(context);
267-
268-
let statictext = context.avm2.classes().statictext;
269-
let object = Avm2StageObject::for_display_object(context.gc(), self.into(), statictext);
270-
// We don't need to call the initializer method, as AVM2 can't link
271-
// a custom class to a StaticText, and the initializer method for
272-
// StaticText itself is a no-op
273-
self.set_object2(context, object);
274-
275-
self.on_construction_complete(context);
276281
}
277282
}
278283

0 commit comments

Comments
 (0)