2010년 3월 22일 월요일

Sprite 클래쓰 - Drag & Drop

 

- startDrag() 메소드

   매개변수로는 lockCenter : Booleanboudns : Rectangle 이 있다.

   lockCenter 가 true일 경우, 드래그하는 무비클립의 (+)점에 마우스 포인터가 일치하게 되고, false일 경우

   에는 드래그를 하는 최초 클릭 시작점에 마우스 포인터가 일치하게 된다.

   bounds는 Rectangle클래스의 속성을 쓰는 것과 마찬가지로 x좌표, y좌표, width, height 를 직접 지정해

   주면 된다.

 

 

 

[code as3]
package classes.view
{
import flash.display.Sprite;
import flash.events.MouseEvent;

public class Drag extends Sprite
{
    public function Drag()
    {
        super();

        buttonMode = true;

        this.addEventListener( MouseEvent.MOUSE_DOWN, startDragHandler );
        this.addEventListener( MouseEvent.MOUSE_UP, stopDragHandler );
    }

    private function startDragHandler( e:MouseEvent ) : void
    {
        this.alpha = 0.5;
        this.startDrag();
    }

    private function stopDragHandler( e:MouseEvent ) : void
    {
        this.alpha = 1;
        this.stopDrag();
    }
}
}
[/code]

 

댓글 2개:

  1. 애플민트 블로그한번 가서 참고해보면 더 도움이 될거 같아용



    http://butibutiuk.textcube.com/18

    답글삭제
  2. @야훔 - 2010/03/23 19:57
    애플민트님 짱이군효 ! ㅋ

    답글삭제