Correctly handle zero-frame MovieClip

A MovieClip with zero frames can still have a child added
through ActionScript, which ticks normally.
This commit is contained in:
Aaron Hill 2024-01-07 23:34:35 -05:00
parent f8219a06e0
commit 6c2e28a08f
7 changed files with 40 additions and 1 deletions

View File

@ -2650,7 +2650,9 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> {
fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) { fn construct_frame(&self, context: &mut UpdateContext<'_, 'gc>) {
// AVM1 code expects to execute in line with timeline instructions, so // AVM1 code expects to execute in line with timeline instructions, so
// it's exempted from frame construction. // it's exempted from frame construction.
if self.movie().is_action_script_3() && self.frames_loaded() >= 1 { if self.movie().is_action_script_3()
&& (self.frames_loaded() >= 1 || self.total_frames() == 0)
{
let is_load_frame = !self.0.read().initialized(); let is_load_frame = !self.0.read().initialized();
let needs_construction = if matches!(self.object2(), Avm2Value::Null) { let needs_construction = if matches!(self.object2(), Avm2Value::Null) {
self.allocate_as_avm2_object(context, (*self).into()); self.allocate_as_avm2_object(context, (*self).into());

View File

@ -0,0 +1,17 @@
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
public function Main() {
var child = MovieClip(this.getChildAt(0));
trace("Child: " + child + " totalFrames: " + child.totalFrames);
child.addChild(new NormalChild());
}
}
}

View File

@ -0,0 +1,14 @@
package {
import flash.display.MovieClip;
public class TraceConstructor extends MovieClip {
public function TraceConstructor() {
trace("Constructed TraceConstructor with name: " + this.name);
}
}
}

View File

@ -0,0 +1,3 @@
Child: [object ZeroFrames] totalFrames: 0
Constructed TraceConstructor with name: child1
Constructed TraceConstructor with name: child2

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
# NOTE - test.swf was manually edited to remove the single (empty) frame,
# so that it actually has zero frames.
num_ticks = 3