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

マウスを追う矢印

Get Adobe Flash player
by Nowloading_ 05 Mar 2011
    Embed
/**
 * Copyright Nowloading_ ( http://wonderfl.net/user/Nowloading_ )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/uycJ
 */

package{
    import flash.display.Sprite;
    import flash.events.Event;
    public class FollowMouse extends Sprite{
        private var arrow:Arrow;
        private var speed:Number = 5;
        public function FollowMouse(){
            init();
        }
        private function init():void{
            arrow = new  Arrow();
            addChild(arrow);
            addEventListener(Event.ENTER_FRAME,onEnterFlame);
        }
        private function onEnterFlame(e:Event):void{
            var dx:Number = mouseX - arrow.x;
            var dy:Number = mouseY - arrow.y;
            var angle:Number = Math.atan2(dy,dx);
            arrow.rotation = angle * 180/Math.PI;
            var vx:Number = Math.cos(angle) *speed;
            var vy:Number = Math.sin(angle) *speed;
            arrow.x += 0.6*vx;
            arrow.y += 0.6*vy;
        }
    }
}

    import flash.display.Sprite;
    
     class Arrow extends Sprite {
        public function Arrow() {
            init();
        }
        public function init():void {
            graphics.lineStyle(3, 0, 1);
            graphics.beginFill(0xff0000);
            graphics.moveTo(-50, -25);
            graphics.lineTo(0, -25);
            graphics.lineTo(0, -50);
            graphics.lineTo(50, 0);
            graphics.lineTo(0, 50);
            graphics.lineTo(0, 25);
            graphics.lineTo(-50, 25);
            graphics.lineTo(-50, -25);
            graphics.endFill();
        }
    }