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).
This commit is contained in:
David Wendt 2021-02-09 22:01:19 -05:00 committed by Mike Welsh
parent a5b4e168d3
commit d90ad1ab08
1 changed files with 7 additions and 1 deletions

View File

@ -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));
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);