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 WinField95 15 Jan 2012
    Embed
/**
 * Copyright WinField95 ( http://wonderfl.net/user/WinField95 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7JPK
 */

package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.GlowFilter;
    
    public class Main extends Sprite
    {
        private var bullet:Sprite;
        
        public function Main()
        {
            
            bullet = new Sprite();
            bullet.graphics.beginFill(0xFFFFFF);
            bullet.graphics.drawCircle(0, 0, 20);
            bullet.graphics.endFill();
            bullet.x = bullet.y = 232;
            addChild(bullet);
            
            bullet.filters = [new GlowFilter(0x000000, 1.0, 20, 20, 2, 1, false, true)];
            
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        
        }
        
        
        private function onEnterFrame(event:Event):void {
                
                var v:Number = -10.0
                var d:Number = Math.atan2(mouseY - bullet.y,mouseX - bullet.x);
                var dis:Number = Math.sqrt((mouseY - bullet.y)* (mouseY - bullet.y) + (mouseX - bullet.x)* (mouseX - bullet.x))
            
                if(dis < 150){
                    bullet.x += Math.cos(d) * v;            
                    bullet.y += Math.sin(d) * v;
                }    
            }
    }
}