Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm1: Correct MovieClipLoader methods #6004

Merged
merged 5 commits into from
Jan 15, 2022
Merged

Conversation

relrelb
Copy link
Contributor

@relrelb relrelb commented Jan 8, 2022

Fixes #917.

Copy link
Member

@Herschel Herschel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment on lines +47 to +59
let target = match target {
Value::String(_) => {
let start_clip = activation.target_clip_or_root()?;
activation.resolve_target_display_object(start_clip, *target, true)?
}
Value::Number(level_id) => {
// Levels are rounded down.
// TODO: What happens with negative levels?
Some(activation.resolve_level(*level_id as i32))
}
Value::Object(object) => object.as_display_object(),
_ => None,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extract this logic into a fn since it's used by several of the methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, they have subtle differences:

  • load_clip uses resolve_level.
  • unload_clip and get_progress use child_by_depth
  • get_progress returns undefined for non-DisplayObject objects.

It might be possible, but I doubt how better it will be.

@relrelb relrelb marked this pull request as ready for review January 15, 2022 14:11
Handle strings, numbers and DisplayObject targets (not just MovieClips).
To support non-MovieClip targets, turn `clip.as_movie_clip().unwrap()`
to `if let Some(mc) = clip.as_movie_clip()` in `Loader`.
Handle strings, numbers and DisplayObject targets.
Handle strings, numbers and DisplayObject targets.
Return compressed length rather than uncompressed length.
Copy link
Member

@Herschel Herschel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Herschel Herschel merged commit 7dad98e into ruffle-rs:master Jan 15, 2022
@relrelb relrelb deleted the mcl branch January 15, 2022 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MovieClipLoader.loadClip/unloadClip should accept a String path
2 participants