From d90ad1ab082d73338f593c7ff92368070b399d3d Mon Sep 17 00:00:00 2001 From: David Wendt Date: Tue, 9 Feb 2021 22:01:19 -0500 Subject: [PATCH] core: Account for the fact that AVM2 constructs objects far earlier than the frame number advances. This is most certainly *not* the correct behavior; though it does work. If I track the frame number in event handlers we can see it change before `enterFrame` is broadcast. However, when I tried to do that, all hell broke loose and every AVM1 and AVM2 test failed (gating the behavior to AVM2 did *not* help). --- core/src/display_object/movie_clip.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index d8a1979a7..ebfd716d5 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -1146,7 +1146,13 @@ impl<'gc> MovieClip<'gc> { child.set_instantiated_by_timeline(context.gc_context, true); child.set_depth(context.gc_context, depth); child.set_parent(context.gc_context, Some(self_display_object)); - child.set_place_frame(context.gc_context, self.current_frame()); + if child.vm_type(context) == AvmType::Avm2 { + // In AVM2 instantiation happens before frame advance so we + // have to special-case that + child.set_place_frame(context.gc_context, self.current_frame() + 1); + } else { + child.set_place_frame(context.gc_context, self.current_frame()); + } if copy_previous_properties { if let Some(prev_child) = prev_child { child.copy_display_properties_from(context.gc_context, prev_child);