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

バネの動きの練習

バネの動きの練習です。
Get Adobe Flash player
by yuugurenote 13 Nov 2011
/**
 * Copyright yuugurenote ( http://wonderfl.net/user/yuugurenote )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bAKr
 */

package {
    import flash.display.Sprite;
    import flash.display.Graphics;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.geom.ColorTransform;
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    [SWF(width=465,height=465,backgroundColor=0x000000,frameRate=60)]

    public class AS111113_01 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var myColor:ColorTransform = new ColorTransform();
        public var viewBmd:BitmapData=new BitmapData(sw,sh,false,0x000000);
        public var viewBmp:Bitmap=new Bitmap(viewBmd);
        public var _mySprite:mySprite;

        public var mySpring:Number=0.1;
        public var myFriction:Number=0.9;
        public var mySpeedX:Number=0;
        public var mySpeedY:Number=0;

        public function AS111113_01() {

            addChild(viewBmp);
            var tmpBmd:BitmapData;
            myColor.redMultiplier=0.9;
            myColor.greenMultiplier=0.9;
            myColor.blueMultiplier=0.9;

            _mySprite = new mySprite();
            _mySprite.x=sw/2-_mySprite.width/2;
            _mySprite.y=sh/2-_mySprite.width/2;
            addChild(_mySprite);

            addEventListener(Event.ENTER_FRAME, xEnter);
            addEventListener(Event.ENTER_FRAME,xDraw);

        }
        public function xDraw(e:Event):void {
            viewBmd.draw(stage,null,myColor);
            viewBmd.applyFilter(viewBmd, viewBmd.rect, new Point(), new BlurFilter(8, 8, 3));
        }

        private function xEnter(e:Event):void {
            var myIntX:Number=mouseX-_mySprite.x;
            var myIntY:Number=mouseY-_mySprite.y;

            mySpeedX+=myIntX*mySpring;
            mySpeedY+=myIntY*mySpring;
            mySpeedX*=myFriction;
            mySpeedY*=myFriction;

            _mySprite.x+=mySpeedX;
            _mySprite.y+=mySpeedY;

        }
    }

}


import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;

class mySprite extends Sprite {

    public function mySprite() {

        this.graphics.beginFill(0x00FF7F,1);
        this.graphics.drawCircle(0,0,5);
        this.graphics.endFill();
    }
}