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