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

Windmill

Get Adobe Flash player
by quail24eggs 29 Mar 2011
    Embed
/**
 * Copyright quail24eggs ( http://wonderfl.net/user/quail24eggs )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9Zfc
 */

package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Rectangle;
    
    public class Main extends Sprite 
    {
        public function Main():void 
        {
        //以下 四角形描写
        var sq1:Sprite = new Sprite();
        var sq2:Sprite = new Sprite();
        var sq3:Sprite = new Sprite();
        var sq4:Sprite = new Sprite();
        var sq5:Sprite = new Sprite();
        mySquare(sq1, 100);
        mySquare(sq2, 140);
        mySquare(sq3, 180);
        mySquare(sq4, 220);
        mySquare(sq5, 260);
        this.addChild(sq1);
        this.addChild(sq2);
        this.addChild(sq3);
        this.addChild(sq4);
        this.addChild(sq5);
        
        function mySquare(sqName:Sprite, m:Number):void //Spriteのプロパティ設定
        {
            sqName.graphics.beginFill(0xFFFFFF* Math.random());
            sqName.x = m;
            sqName.y = m;
            sqName.alpha = 0.3;
            sqName.graphics.drawRect(0, 0, 100, 100);
        }
        
//以下 回転 描写
            
            addEventListener(Event.ENTER_FRAME, xRotate);
            function xRotate(eventObject:Event):void 
            {
                sq1.rotationY += yDeg(sq1);
                sq2.rotationY += yDeg(sq2);
                sq3.rotationY += yDeg(sq3);
                sq4.rotationY += yDeg(sq4);
                sq5.rotationY += yDeg(sq5);
            }
            
            function yDeg(k:Sprite):Number
            {
                var dec:Number = 0.01; //減速率
                var n:Number = (mouseX - k.x) * dec; //距離に比例した回転速度
                n += 180;
                n %= 360;
                n += 360;
                n %= 360;
                n -= 180;
                //-180≦n≦180
                return n;
            }
            
        }
    }
}