Skip to content

Commit

Permalink
core: Fix regressions in avm1 buttons
Browse files Browse the repository at this point in the history
Closes #18610.
  • Loading branch information
Toad06 authored and torokati44 committed Nov 17, 2024
1 parent 114d24f commit d1466ee
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion core/src/display_object/movie_clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ impl<'gc> MovieClip<'gc> {
.intersects(ClipEvent::BUTTON_EVENT_FLAGS)
{
true
} else if self.is_root() {
} else if self.avm1_parent().is_none() {
false
} else {
let object = self.object();
Expand Down
6 changes: 3 additions & 3 deletions tests/tests/swfs/avm1/root_button_mode/input.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[
{
"type": "Wait"
},
{
"type": "Wait"
},
Expand Down Expand Up @@ -60,9 +63,6 @@
"pos": [150.0, 150.0],
"btn": "Left"
},
{
"type": "Wait"
},
{
"type": "Wait"
}
Expand Down
6 changes: 6 additions & 0 deletions tests/tests/swfs/avm1/root_button_mode/output.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
_level0.mc2.onMouseDown
_level0.onMouseDown
_level0.mc2.onMouseUp
_level0.onMouseUp
_level0.mc2.onMouseDown
_level0.onMouseDown
_level0.mc2.onPress
_level0.mc2.onMouseUp
_level0.onMouseUp
_level0.mc2.onRelease
17 changes: 13 additions & 4 deletions tests/tests/swfs/avm1/root_button_mode/source.as
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Test made with JPEXS Free Flash Decompiler.

function createMC(name, x, y) {
var mc = _root.createEmptyMovieClip(name, _root.getNextHighestDepth());
function createMC(name, x, y, parent) {
var mc = parent.createEmptyMovieClip(name, parent.getNextHighestDepth());
mc._x = x;
mc._y = y;
mc.beginFill(0xFF0000);
Expand All @@ -28,5 +28,14 @@ function setFunctions(mc) {
};
}

createMC("square", 0, 0);
setFunctions(_root);
if(this === _level0) {
createMC("square", 0, 0, this);
setFunctions(this);
// Issue #18610.
this.createEmptyMovieClip("mc2", this.getNextHighestDepth());
loadMovie("test.swf", "mc2");
} else {
this._lockroot = true;
createMC("square", 100, 100, this);
setFunctions(this);
}
Binary file modified tests/tests/swfs/avm1/root_button_mode/test.swf
Binary file not shown.

0 comments on commit d1466ee

Please sign in to comment.