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 2012-9-28

Get Adobe Flash player
by mutantleg 28 Sep 2012
    Embed
/**
 * Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3uEx
 */

package {
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.Graphics;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public var obst:Sprite;
        
        public function FlashTest() {
           
           var g:Graphics;
           obst = new Sprite();
           g = obst.graphics;
           g.clear();
           g.lineStyle(2,0);
           g.drawRect(-64,-16,128,32);
           addChild(obst);
           
           obst.x = 200;
           obst.y = 100;
            
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, mdown);
        }//ctor
        
        public function mdown(e:MouseEvent):void
        {
            px = mouseX;
            py = mouseY;
         }//mdown
        
        public var px:Number = 200;
        public var py:Number = 200;
        public var pr:Number = 8;
        public var obsta:Number = 0;
        
        public function onEnter(e:Event):void
        {
            graphics.clear();
            graphics.lineStyle(2,0);
            graphics.drawCircle(px,py, pr);
            
            var rs:Number;
            rs = 0.05;
            obsta += rs;
            obst.rotation = obsta * (180/3.1415);
            
            
            var mag:Number;
            var nx:Number;
            var ny:Number;
            var dx:Number;
            var dy:Number;
            var ix:Number;
            var iy:Number;
            var jx:Number;
            var jy:Number;
            var rx:Number;
            var ry:Number;
            var kx:Number;
            var ky:Number;
            var cx:Number;
            var cy:Number;
            var ia:Number;
            var a:Number;
            a = obsta;
            ia = -a;
            
            kx = obst.x;
            ky = obst.y;
            
            jx = px - kx;
            jy = py - ky;
            
            rx = jx * Math.cos(ia) - Math.sin(ia)*jy;
            ry = jx * Math.sin(ia) + Math.cos(ia)*jy;
            
            if (rx <  -64) { ix = -64;}
            else if (rx >  64) { ix =  64;}
            else ix = rx;
            
            if (ry < -16) { iy =  -16;}
            else if (ry > 16) { iy =  16;}
            else iy = ry; 
            
            cx = ix * Math.cos(a) - Math.sin(a) * iy;
            cy = ix * Math.sin(a) + Math.cos(a) * iy;
            
            cx += kx;
            cy += ky;
            
            graphics.drawCircle(cx,cy, 4);
            graphics.moveTo(px,py);
            graphics.lineTo(cx,cy);
            
            dx = px - cx;
            dy = py - cy;
            mag = Math.sqrt(dx*dx+dy*dy);
            if (mag == 0) { mag = 0.00000000001;}
            if (mag > pr) { return; }
            
            px -= kx;
            py -= ky;
            
            rx = px * Math.cos(rs) - Math.sin(rs) * py;
            ry = px * Math.sin(rs) + Math.cos(rs) * py;
            
            px = rx + kx;
            py = ry + ky;
            
            
        }//onenter
        
        
    }//classend
}