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

394969 ( illusion clock )

library

... 時計を波形で表すテスト。全く錯視になっていませんが。。

@author rettuce
Get Adobe Flash player
by rettuce 01 Aug 2010
/**
 * Copyright rettuce ( http://wonderfl.net/user/rettuce )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iyVl
 */

package 
{
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.utils.Timer;
    
    // library
    import caurina.transitions.Tweener;
    
    [SWF(width = 465, height = 465, backgroundColor = 0x000000, frameRate = 30)]
    /**
     * ... 時計を波形で表すテスト。全く錯視になっていませんが。。
     * 
     * @author rettuce
     */
    public class DocumentClass extends Sprite 
    {
        private const MAX_BALLSET_NUM:int = 35;
        private const MAX_BALL_NUM:int = 6;
        private var STG_H:Number;
        
        private var BALL_SIZE:int = 5;
        private var LINE_WEIGHT:int = 3;
        private var EAS_TIME:Number = 2;
        private var EAS_VAL:String = "easeOutQuart";
        
        private var _ballSetArr:Array = [];
        private var _lineArr:Array = [];
        private var _colorArr:Array = [];
        
        public function DocumentClass()
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            
            STG_H = stage.stageHeight *2;
            
            ballSet();
            addEventListener(Event.ENTER_FRAME, lineDraw );
            stage.addEventListener(MouseEvent.CLICK, worldChange );
        }
        
        private function worldChange(e:Event ):void
        {
            LINE_WEIGHT += 1;
            EAS_TIME += 0.5;
        }
        
        private function ballSet():void
        {
            for ( var m:int = 0; m < MAX_BALLSET_NUM; m++) {
                var ballArr:Array = [];
                var color:Number = 0xFFFFFF * Math.random();
                _colorArr.push(color);
                
                for ( var i:int = 0; i < MAX_BALL_NUM; i++) {
                    var ball:Shape = new Shape();
                    ball.graphics.beginFill(color);
                    ball.graphics.drawCircle(0, 0, BALL_SIZE);
                    ball.graphics.endFill();
                    
                    ball.x =  (i+1)* (stage.stageWidth / (MAX_BALL_NUM +1));
                    ball.y = ( STG_H  /  MAX_BALLSET_NUM) ;
                    ball.y -= ( STG_H / (MAX_BALLSET_NUM )) * m;
                    
                    addChild(ball);
                    ballArr.push(ball);                
                }
                var line:Shape = new Shape();
                addChild(line);
                _lineArr.push(line);
                _ballSetArr.push(ballArr)
            }
        }
        
        private function lineDraw(e:Event = null):void
        {
            timeSet();
            for ( var m:int = 0; m < MAX_BALLSET_NUM; m++) {
                var h:Number = ( stage.stageHeight / (MAX_BALLSET_NUM + 2)) * (m + 1) ;
                var line:Shape = _lineArr[m];
                line.graphics.clear();
                line.graphics.lineStyle( LINE_WEIGHT, _colorArr[m] );
                line.graphics.moveTo(0, h);
                
                for ( var n:int = 0; n < MAX_BALL_NUM; n++)
                {
                    line.graphics.lineTo( _ballSetArr[m][n].x, _ballSetArr[m][n].y ); 
                }
                
                line.graphics.lineTo(stage.stageWidth, h );
                line.graphics.endFill();
            }
        }
        
        private function timeSet():void 
        {
            var time:Date = new Date();
            
            var s1:Number =  Math.floor( time.getSeconds() / 10 );     // 0 - 6
            var s2:Number =  time.getSeconds() % 10;                   // 0 - 9
            var m1:Number =  Math.floor( time.getMinutes() / 10 );     // 0 - 6
            var m2:Number =  time.getMinutes() % 10;                   // 0 - 9
            var h1:Number =  Math.floor( time.getHours() / 10 );       // 0 - 2
            var h2:Number =  time.getHours()% 10;                      // 0 - 9
            
            s1 = ( 3 - s1 ) * (stage.stageHeight / 8  );
            s2 = ( 5 - s2 ) * (stage.stageHeight / 11 );
            m1 = ( 3 - m1 ) * (stage.stageHeight / 8  );
            m2 = ( 5 - m2 ) * (stage.stageHeight / 11 );
            h1 = ( 1 - h1 ) * (stage.stageHeight / 4  );
            h2 = ( 5 - h2 ) * (stage.stageHeight / 11 );
            
            for (var i:int = 0; i < MAX_BALLSET_NUM; i++ )
            {    
                var SET_Y:Number = ( STG_H / (MAX_BALLSET_NUM)) * i - stage.stageHeight/2  ;
                
                Tweener.addTween( _ballSetArr[i][4], { y:SET_Y + s1, time:EAS_TIME, transition:EAS_VAL } );
                Tweener.addTween( _ballSetArr[i][5], { y:SET_Y + s2, time:EAS_TIME, transition:EAS_VAL } );
                Tweener.addTween( _ballSetArr[i][2], { y:SET_Y + m1, time:EAS_TIME, transition:EAS_VAL } );
                Tweener.addTween( _ballSetArr[i][3], { y:SET_Y + m2, time:EAS_TIME, transition:EAS_VAL } );
                Tweener.addTween( _ballSetArr[i][0], { y:SET_Y + h1, time:EAS_TIME, transition:EAS_VAL } );
                Tweener.addTween( _ballSetArr[i][1], { y:SET_Y + h2, time:EAS_TIME, transition:EAS_VAL } );
            }
        }
        
    }    
}