用滑鼠可以拖曳黃色和綠色的平行四邊形,拖曳到正確的相對應框框裡,就會顯示 Ture,差太多就顯示 False。程式碼如下:

[@more@]

  1. left_move.addEventListener(MouseEvent.MOUSE_DOWN, movieleft);
  2. left_move.addEventListener(MouseEvent.MOUSE_UP, Stopleft);
  3. right_move.addEventListener(MouseEvent.MOUSE_DOWN, movieRight);
  4. right_move.addEventListener(MouseEvent.MOUSE_UP, movieStop);
  5.  
  6. function movieRight(e:MouseEvent) {
  7. right_move.startDrag(true);
  8. } //右邊拖曳
  9. function movieleft(e:MouseEvent) {
  10. left_move.startDrag(true);
  11. } //左邊拖曳
  12. function movieStop(event:MouseEvent)
  13. {
  14.     right_move.stopDrag();
  15.     txt.text = String(right_move.hitTestPoint(right1.x,right1.y,true)) ;
  16. }
  17. //滑鼠放開時停止拖曳,並偵測是否碰撞
  18. function Stopleft(event:MouseEvent)
  19. {
  20.     left_move.stopDrag();
  21.     left_txt.text = String(left_move.hitTestPoint(left1.x,left1.y,true)) ;
  22. }
最後修改日期: 2021 年 3 月 18 日

作者