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 2016-3-2

Get Adobe Flash player
by mutantleg 02 Mar 2016
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/a2vq
 */

package {
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
        
          stage.addEventListener(MouseEvent.CLICK, onClick);    
          stage.addEventListener(Event.ENTER_FRAME, onEnter);  
        }//ctor
        
        public function onClick(e:MouseEvent):void
        { xrad=Math.random()*32+16; yrad=Math.random()*32+16;    }
        
        public var cx:Number = 0;
        public var cy:Number = 0;
        public var xrad:Number = 32;
        public var yrad:Number = 32;
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2,0);
            
            var mx:Number; var my:Number;
            mx = stage.mouseX; my = stage.mouseY;
            
            var ms:Number; 
            var vx:Number; var vy:Number;
            vx = mx-cx; vy =my-cy;
            ms = 8;
            if (vx>ms){vx=ms;}else if(vx<-ms){vx=-ms;}
            if (vy>ms){vy=ms;}else if(vy<-ms){vy=-ms;}
            cx +=vx; cy+=vy;
 
             graphics.moveTo(mx,my);
             graphics.lineTo(cx,cy);
            
         //   graphics.drawRect(cx-xrad,cy-yrad,xrad*2,yrad*2);
            
            var ax:Number; var ay:Number;
            var ix:Number; var iy:Number;
            var r:Number;
            r=32;
            r=64;

            ax = 230; ay = 230;
            graphics.drawCircle(ax,ay, r);
            
            if (ax < cx-xrad) { ix = cx-xrad;}
            else if (ax > cx+xrad) { ix = cx+xrad; }
            else { ix = ax; } 
                        
            if (ay < cy-yrad) { iy = cy-yrad;}
            else if (ay > cy+yrad) { iy = cy+yrad; }
            else { iy = ay; } 
            
            graphics.drawCircle(ix,iy,4);
            
            var nx:Number; var ny:Number; var mag:Number;
            nx = ix-ax;  ny = iy-ay;
            mag = Math.sqrt(nx*nx+ny*ny);
            if (mag < r)
            {
             if (mag == 0) { mag = 0.0001; }
             nx/=mag; ny/=mag;
             cx += nx * (r-mag);
             cy += ny * (r-mag);
            }//endif
                 
            graphics.drawRect(cx-xrad,cy-yrad,xrad*2,yrad*2);
            
            
             
            /*
            var ax:Number; var ay:Number;
            var axrad:Number; var ayrad:Number;
            
            ax= 230; ay =230;
            axrad= 32; ayrad=32;
            graphics.drawRect(ax-axrad,ay-ayrad,axrad*2,ayrad*2);
            
            
            var ix:Number; var iy:Number;
            
            if (cx+xrad < ax-axrad) { ix = ax-axrad; }
            else if (cx -xrad > ax+axrad) { ix = ax+axrad;}
            else { if (cx<ax-axrad) { ix = ax-axrad;}
              else if (cx > ax+axrad) { ix =ax+axrad;}
              else {ix = cx; }  }

            if (cy+yrad < ay-ayrad) { iy = ay-ayrad; }
            else if (cy -yrad > ay+ayrad) { iy = ay+ayrad;}
            else { if (cy<ay-ayrad) { iy = ay-ayrad;}
              else if (cy > ay+ayrad) { iy =ay+ayrad;}
              else {iy = cy; }  }
            
            graphics.drawCircle(ix, ay, 4);
            graphics.drawCircle(ax, iy, 4);
            graphics.drawCircle(ix, iy, 4);
            
            */
            
            
            
            
            
        }//onenter
        
    }//classend
}