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-11-12

Get Adobe Flash player
by mutantleg 11 Nov 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/CRFk
 */

package {
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
          stage.addEventListener(MouseEvent.MOUSE_DOWN, onMdown);
          stage.addEventListener(MouseEvent.MOUSE_UP, onMup);  
          stage.addEventListener(Event.ENTER_FRAME, onEnter);  
        }//ctor
        
        public function onMdown(e:MouseEvent):void { mbutton = 1; }
        public function onMup(e:MouseEvent):void { mbutton = 0; }
        
        public var camx:Number = 0;
        public var camy:Number = 0;
        
        public var cx:Number = 230;
        public var cy:Number = 230;
        public var mbutton:int = 0;
       
        public var gx:Number = 230;
        public var gy:Number = 230;
       
       public function onEnter(e:Event):void
       {
          graphics.clear();
          graphics.lineStyle(2, 0);
          
          var mx:Number; var my:Number;
          var sx:Number; var sy:Number;
          var wmx:Number; var wmy:Number;          
          
          mx = stage.mouseX; my = stage.mouseY;
          sx = camx; sy = camy;
          wmx = sx+mx; wmy = sy+my;
          
          mx = stage.mouseX;
          my = stage.mouseY;
          
          graphics.drawRect(0-sx,0-sy, 465, 465);
          
          graphics.drawCircle(cx-sx,cy-sy, 16);
          
          graphics.drawCircle(wmx-sx,wmy-sy, 4);
          
          graphics.drawRect(gx-4-sx,gy-4-sy,8,8);
                   
          var ta:Number; var ms:Number;
          var mag:Number;
          var dx:Number; var dy:Number;
          
          if (mbutton > 0)
          { gx=wmx; gy=wmy; }
          
          
          dx = gx-cx;         dy = gy-cy;
          mag = Math.sqrt(dx*dx+dy*dy);
          
          
          ms = 4;
          ta = Math.atan2(gy-cy, gx-cx);
          
          if (mag > ms)
          { 
            cx += Math.cos(ta) * ms;
            cy += Math.sin(ta) * ms;
            
          }//endif
          
          
          camx += ((cx-230)-camx)*0.1;
          camy += ((cy-230)-camy)*0.1;
          
           
       }//onenter 
        
    }//classend
}