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

ffx2: the rotating rectangle

DO NOT GET CLOSE TO YOUR DISPLAY when you watch this swf.
画面から十分に離れてからご覧になってください.

click the stage.
イメージしたものとちょっと違うような...
/**
 * Copyright matacat ( http://wonderfl.net/user/matacat )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ivzw
 */

// forked from matacat's ff: the rotating rectangle
// forked from o8que's the rotating rectangle
package {
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    
    [SWF(width="465",height="465",frameRate="60",backgroundColor="0xFFFFFF")]
    public class Main extends Sprite {
        
        public function Main() {
            const sw:int = stage.stageWidth;
            const sh:int = stage.stageHeight;
            const bw:int = 5;
            const bh:int = sh>>1;
            const rw:int = 20;
            const rh:int = bh>>1;
            
            var t:Number = 0;
            addEventListener(Event.ENTER_FRAME,
                function(e:Event):void { t = t>sw?-rw:t+1; }
            );
            
            var bgbd:BitmapData = new BitmapData(bw*2,bh*2,false,0x99CC99);
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0x003300);
            s.graphics.drawRect(0,0,bw,bh);
            s.graphics.drawRect(bw,bh,bw,bh);
            bgbd.draw(s);
            graphics.beginBitmapFill(bgbd);
            graphics.drawRect(0,0,sw,sh);
            
            s.graphics.clear();
            s.graphics.beginFill(0x666666);
            s.graphics.drawRect(0,bh-rh>>1,rw,rh);
            addChild(s);
            s.addEventListener(Event.ENTER_FRAME,
                (function():Function {
                    var self:Sprite = s;
                    return function(e:Event):void { self.x = t; }
                })()
            );
            
            s = new Sprite();
            s.graphics.beginFill(0x666666);
            s.graphics.drawRect(0,bh+(bh-rh>>1),rw,rh);
            addChild(s);
            s.addEventListener(Event.ENTER_FRAME,
                (function():Function {
                    var self:Sprite = s;
                    return function(e:Event):void { self.x = t; }
                })()
            );
            
            s = new Sprite();
            s.graphics.beginFill(0xFFFFFF);
            s.graphics.drawRect(-rw*2,0,rw*5,sh);
            s.graphics.lineStyle(1,0xFF0000);
            s.graphics.moveTo(rw>>1,0);
            s.graphics.lineTo(rw>>1,sh);
            s.visible=false;
            addChildAt(s,0);
            s.addEventListener(Event.ENTER_FRAME,
                (function():Function {
                    var self:Sprite = s;
                    return function(e:Event):void { self.x = t; }
                })()
            );
            
            stage.addEventListener(MouseEvent.CLICK,
                function(e:MouseEvent):void { s.visible = !s.visible; }
            );
        }
    }
}