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: forked from: ドラッグする

Get Adobe Flash player
by herotta 02 Sep 2011
    Embed
/**
 * Copyright herotta ( http://wonderfl.net/user/herotta )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/phy2
 */

// forked from kwst.andromeda.ma's forked from: ドラッグする
// 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(0xB3E333);
            circle.graphics.drawCircle(0,0,200);
            circle.graphics.endFill();

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

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

            //表示リストに追加
            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();
        }
    }
}