Posted By

lzyy on 09/17/08


Tagged

getObjectsUnderPoint


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

THEPWN3R
iamgowan


getObjectsUnderPoint


 / Published in: ActionScript 3
 

获得当前Point下面的DisplayObject数组

  1. import flash.display.Sprite;
  2. import flash.geom.Point;
  3.  
  4. var container:Sprite = new Sprite();
  5.  
  6. var square1:Sprite = new Sprite();
  7. square1.graphics.beginFill(0xFFCC00);
  8. square1.graphics.drawRect(0, 0, 40, 40);
  9.  
  10. var square2:Sprite = new Sprite();
  11. square2.graphics.beginFill(0x00CCFF);
  12. square2.graphics.drawRect(20, 0, 30, 40);
  13.  
  14. container.addChild(square1);
  15. container.addChild(square2);
  16.  
  17. var pt:Point = new Point(10, 20);
  18. var objects:Array = container.getObjectsUnderPoint(pt);
  19. trace(objects.length); // 1
  20.  
  21. pt = new Point(35, 20);
  22. objects = container.getObjectsUnderPoint(pt);
  23. trace(objects.length); // 2

Report this snippet  

You need to login to post a comment.