Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/src/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2554,6 +2554,11 @@ pub trait TDisplayObject<'gc>:
.unwrap_or(Avm1Value::Undefined)
}

#[no_dynamic]
fn object1_or_null(self) -> Avm1Value<'gc> {
self.object1().map(|o| o.into()).unwrap_or(Avm1Value::Null)
}

/// Equivalent to `self.object1_or_undef().coerce_to_object_or_bare()`, but avoids
/// the need for an activation.
///
Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ pub trait TInteractiveObject<'gc>:
let self_do = self.as_displayobject();
if let Some(object) = self_do.object1() {
let other = other
.map(|d| d.as_displayobject().object1_or_undef())
.map(|d| d.as_displayobject().object1_or_null())
.unwrap_or(Avm1Value::Null);

let method_name = if focused {
Expand Down
4 changes: 2 additions & 2 deletions core/src/focus_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ impl<'gc> FocusTracker<'gc> {
istr!(context, "onSetFocus"),
&[
old.map(|o| o.as_displayobject())
.map(|v| v.object1_or_undef())
.map(|v| v.object1_or_null())
.unwrap_or(Value::Null),
new.map(|o| o.as_displayobject())
.map(|v| v.object1_or_undef())
.map(|v| v.object1_or_null())
.unwrap_or(Value::Null),
],
context,
Expand Down
21 changes: 21 additions & 0 deletions tests/tests/swfs/avm2/selection_onsetfocus_mixed_avm/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package {

import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;


public class Test extends MovieClip {


public function Test() {
super();
var loader:Loader = new Loader();
loader.load(new URLRequest("avm1.swf"));
this.buttonMc.buttonMode = true;
addChild(loader);
}

}

}
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/tests/swfs/avm2/selection_onsetfocus_mixed_avm/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{ "type": "Wait" },
{ "type": "Wait" },
{ "type": "KeyDown", "key": "Tab" },
{ "type": "KeyUp", "key": "Tab" },
{ "type": "KeyDown", "key": "Tab" },
{ "type": "KeyUp", "key": "Tab" },
{ "type": "KeyDown", "key": "Tab" },
{ "type": "KeyUp", "key": "Tab" },
{ "type": "KeyDown", "key": "Tab" },
{ "type": "KeyUp", "key": "Tab" },
{ "type": "MouseDown", "pos": [1, 1], "btn": "Left" },
{ "type": "MouseUp", "pos": [1, 1], "btn": "Left" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
null null
null null
null null
txt.onSetFocus: null
txt.onKillFocus: null
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 3
Loading