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-8-23

Get Adobe Flash player
by mutantleg 23 Aug 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/9JMj
 */

package {
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        
        public var ax:Number = 40;
        public var bx:Number = 240;
        public var dx:Number = 0;
        public function FlashTest() {
            // write as3 code here..
            
            
            btn1 = new Sprite();
            btn1.graphics.beginFill(0,1);
            btn1.graphics.drawRect(0,0,64,64);
            addChild(btn1);
            btn1.x = 100;
            btn1.y = 150;
            
            btn2 = new Sprite();
            btn2.graphics.beginFill(0xFF0000,1);
            btn2.graphics.drawRect(0,0,64,64);
            addChild(btn2);
            btn2.x = 250;
            btn2.y = 150;      
            
            jx = ax;
                  
            stage.addEventListener(Event.ENTER_FRAME, onEnter);
        }//ctor
        
        
        public var btn1:Sprite;
        public var btn2:Sprite;
        
        public var jx:Number = 0;
        
        public function onEnter(e:Event):void
        {
            
            graphics.clear();
            graphics.lineStyle(1,0);
            graphics.moveTo(ax,100);
            graphics.lineTo(bx,100);
            graphics.drawCircle(ax,100,16);
            graphics.drawCircle(bx,100,16);
            graphics.drawCircle(this.mouseX, mouseY, 24);
            graphics.drawCircle(jx, 80, 16);
               
            if (btn1.hitTestPoint(mouseX,mouseY)) { jx += 8;}
            if (btn2.hitTestPoint(mouseX,mouseY)) { jx -= 8;}   
               
               
                  if (jx > bx) { jx = ax;}
                  if (jx < ax) { jx = ax;}
               
            getDist(jx);   
               
        }//onenter
        
        public function getDist(kx:Number):void
        {
            var ix:Number;
            var mx:Number;
           // if (kx < ax) { ix = ax; }
           // else if (kx > bx) { ix = bx;}
            
     
            if (kx > dx) { dx = kx; }
           if (dx >= bx) { dx = ax;  } 
            
            graphics.lineStyle(5,0);
            graphics.moveTo(ax, 100);
            graphics.lineTo(dx, 100);
            
         }//getdist
        
        
    }//classend
}