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

flash on 2015-8-23

Get Adobe Flash player
by mutantleg 23 Aug 2015
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eSEr
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        public var cx:Number = 200;
        public var cy:Number = 100;
        
        public function getMag(ax:Number, ay:Number):Number 
        { return Math.sqrt(ax*ax+ay*ay);}
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2, 0);
            
            var wx:Number; var wy:Number; var wr:Number;
            wx=230;        wy = 230; wr = 64;
            
            graphics.drawCircle(wx,wy, wr);
            
            graphics.drawCircle(cx, cy, 8);
            
            var ta:Number;
            ta = Math.atan2(wy-cy, wx-cx);
            graphics.moveTo(cx,cy);
            graphics.lineTo(cx+Math.cos(ta)*8, cy+Math.sin(ta)*8);
            
            cx += Math.cos(ta) * 8;
            cy += Math.sin(ta) * 8;
            
            var d:Number;
            d = getMag(cx-wx,cy-wy);
            if (d < wr+8) {  cx = wx - Math.cos(ta)*(wr+8); cy = wy- Math.sin(ta)*(wr+8);  }
            
            var ax:Number;  var ay:Number;
            var vx:Number; var vy:Number;
            var ms:Number;
            ms = 32; ms = 64;
            ax = cx;  ay = cy;
            vx = Math.sin(ta)*ms; vy = -Math.cos(ta)*ms;
        
            ax += vx; ay += vy;
            
         
            graphics.lineStyle(1, 0);
            graphics.moveTo(cx,cy); graphics.lineTo(cx+vx, cy+vy);

       
            graphics.drawCircle(ax,ay, 8);
 
            ta = Math.atan2(wy-ay, wx-ax);        
            d = getMag(ax-wx,ay-wy);
            if (d > wr+8) { ax = wx - Math.cos(ta)*(wr+8); ay = wy- Math.sin(ta)*(wr+8);  }
         
 
            graphics.lineStyle(2, 0xFF0000);
            graphics.drawCircle(ax,ay, 8);
            graphics.moveTo(cx,cy);  graphics.lineTo(ax,ay);
            
            
            ta = Math.atan2(ay-cy, ax-cx);
            cx += Math.cos(ta);
            cy += Math.sin(ta);
            
            
            
        }//onenter
        
    }//classend
}