In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: ドラッグする

Get Adobe Flash player
by hacker_77w5wopa 15 Oct 2010
/**
 * Copyright hacker_77w5wopa ( http://wonderfl.net/user/hacker_77w5wopa )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1lnG
 */

// forked from 9re's ドラッグする
package{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class MouseDrag extends Sprite { 
        public function MouseDrag(){
            var circle:Sprite = new Sprite();
            //円を描く
            circle.graphics.beginFill(0x333333);
            circle.graphics.drawCircle(0,0,20);
            circle.graphics.endFill();

            //手のカーソルに変更
            circle.buttonMode = true;

            //位置の調節
            circle.x=232;
            circle.y=232;

            //表示リストに追加
            addChild(circle);

            circle.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
            circle.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
        }

        //マウス・ダウン時にドラッグ開始
        private function onMouseDown(e:MouseEvent):void
        {
            e.currentTarget.startDrag();
        }

        //マウス・アップ時にドラッグ終了
        private function onMouseUp(e:MouseEvent):void
        {
            e.currentTarget.stopDrag();
        }
    }
}