File tree 1 file changed +21
-4
lines changed
core/src/avm2/globals/flash/display 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -743,11 +743,28 @@ pub fn hit_test_point<'gc>(
743
743
let y = args. get_f64 ( activation, 1 ) ?;
744
744
let shape_flag = args. get_bool ( 2 ) ;
745
745
746
- // Transform the coordinates from root to world space.
746
+ let avm_root = dobj. avm2_root ( ) ;
747
+ let is_player_root = match avm_root {
748
+ // We can detect the root of the player by the fact that it doesn't have a loader.
749
+ Some ( root) => root
750
+ . loader_info ( )
751
+ . as_ref ( )
752
+ . and_then ( |loader_info| loader_info. as_loader_info_object ( ) )
753
+ . and_then ( |loader_info_obj| loader_info_obj. loader ( ) )
754
+ . is_none ( ) ,
755
+ None => false ,
756
+ } ;
757
+
747
758
let local = Point :: from_pixels ( x, y) ;
748
- let global = dobj
749
- . avm2_root ( )
750
- . map_or ( local, |root| root. local_to_global ( local) ) ;
759
+ let global = if is_player_root {
760
+ // If this root is the root of the player, match avm1 hitTest behavior and treat the
761
+ // input as root-relative coordinates (even if no longer a direct child of the stage)
762
+ avm_root. unwrap ( ) . local_to_global ( local)
763
+ } else {
764
+ // Otherwise, the docs are truthful and the coordinates are relative to the stage
765
+ // (aka nothing for us to do)
766
+ local
767
+ } ;
751
768
752
769
if shape_flag {
753
770
if !dobj. is_on_stage ( activation. context ) {
You can’t perform that action at this time.
0 commit comments