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 2013-3-18

Get Adobe Flash player
by J.J 17 Mar 2013
    Embed
/**
 * Copyright J.J ( http://wonderfl.net/user/J.J )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cfqp
 */

package {
    import flash.events.Event;
    import fl.motion.easing.Elastic;
    import com.flashdynamix.motion.Tweensy;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    import flash.filters.BevelFilter;
    import flash.display.MovieClip;
    import flash.display.Shape;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var w:Number,h:Number
        private var bound:Shape
        private var radius:Number=100
        private var centerX:Number,centerY:Number
        private var handle:MovieClip
        public function FlashTest() {
            w=stage.stageWidth,h=stage.stageHeight;
            stage.frameRate=60;
            bound=new Shape;
            bound.graphics.beginFill(0x000000)
            bound.graphics.drawCircle(0,0,radius)
            bound.graphics.endFill()
            centerX=w/2;
            centerY=h/2
            bound.x=centerX
            bound.y=centerY
            bound.alpha=.5
            this.addChild(bound)
            handle=new MovieClip;
            handle.graphics.copyFrom(bound.graphics)
            handle.scaleX=handle.scaleY=.3;
            handle.x=bound.x,handle.y=bound.y;
            var bevelfilter:BevelFilter=new BevelFilter;
            bevelfilter.blurX=bevelfilter.blurY=45;
            bevelfilter.strength=.5,bevelfilter.distance=20;
            handle.filters=[bevelfilter,new DropShadowFilter()]
            this.addChild(handle)
            handle.addEventListener(MouseEvent.MOUSE_DOWN,onMouse_Down)
            stage.addEventListener(MouseEvent.MOUSE_UP,onMouse_Up)
            addEventListener(Event.ENTER_FRAME,loop)
            // write as3 code here..
            
        }
        private function loop(e:Event):void{
          this.graphics.clear();
          this.graphics.lineStyle(20)
          this.graphics.moveTo(centerX,centerY)
          this.graphics.lineTo(handle.x,handle.y);
          }
        private function onMouse_Down(e:MouseEvent):void{
            stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouse_Move)
        }
        private function onMouse_Up(e:MouseEvent):void{
            stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMouse_Move)
            Tweensy.to(handle,{x:centerX,y:centerY},1,Elastic.easeOut)
        }
        private function onMouse_Move(e:MouseEvent):void{
          var a:Number=stage.mouseX-centerX;
          var b:Number=stage.mouseY-centerY;
          var cbuff:Number=(a*a)+(b*b);
          var c:Number=Math.sqrt(cbuff)
          var cos:Number=a/c
          var sin:Number=b/c
          if(c<radius){
           handle.x=stage.mouseX;
           handle.y=stage.mouseY
           }else{
            handle.x=centerX+radius*cos;
            handle.y=centerY+radius*sin
           }
        }
    }
}