Skip to content

Conversation

@Lord-McSweeney
Copy link
Collaborator

@Lord-McSweeney Lord-McSweeney commented Nov 15, 2025

The first two commits are not observable by code (except in stack traces that will now include Sprite.constructChildren). The third commit fixes a minor issue with child construction-

construct_frame is called on the children of a MovieClip each frame, except on the first. This ensures children that were placed earlier in the frame lifecycle are properly instantiated. On the first frame of a MovieClip, the constructor for Sprite (super() in a subclass) calls Sprite.constructChildren to manually construct each child that was placed on the timeline in the first frame. This PR makes sure that these first-frame children are never constructed by the usual "construct_frame on every frame" logic by setting a new FRAME_CONSTRUCT_SKIPPED flag on them.

Closes #2916

This change should not be observable, as no other `DisplayObject` subclasses can have timeline children
Also make them standalone functions instead of associated methods.

Previously, they were associated methods on `TDisplayObject`, but they didn't
actually access the `DisplayObject` they were called on
…antiation

Often, `MovieClip`s have children that are placed before the `MovieClip`'s
AVM2 side is allocated and instantiated. These children will be instantiated
in the `super()` constructor (specifically, the `Sprite.constructChildren`
call), rather than in-line with normal frame construction. However, if the
`super()` constructor is /never/ called, these children will never be
instantiated. This commit adds a flag that is set on such early children.
Children with this flag set will never have `construct_frame` called on them
during normal frame construction.

Also add test coverage
@Lord-McSweeney Lord-McSweeney added waiting-on-review Waiting on review from a Ruffle team member A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) labels Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) waiting-on-review Waiting on review from a Ruffle team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AVM2: Child objects should be instantiated and assigned by super constructor

2 participants