UNIQLOCKの演出パクリ。

by seino forked from fizzbuzz (diff: 78)
♥0 | Line 74 | Modified 2010-06-08 14:21:01 | MIT License
play

ActionScript3 source code

/**
 * Copyright seino ( http://wonderfl.net/user/seino )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/xCeE
 */

// forked from kagetiyo523's fizzbuzz
package {
    import flash.display.Sprite;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    [SWF(width="200", height="70", backgroundColor="#FFFFFF", frameRate="50")] 
     public class fizzbuzz extends Sprite {
      private var timer:Timer;
      private var date:Date  = new Date();
        public function fizzbuzz() {
           var tf:TextField = new TextField();
           var curtain:Curtain = new Curtain();
           stage.addChild(curtain);
           stage.addChild(tf);
           tf.x = stage.stageWidth /2 - tf.width/2;
           tf.y = 0;
           timer = new Timer(1000);
           timer.addEventListener("timer", function():void{
                                           tf.defaultTextFormat = new TextFormat(""
                                                                                ,30
                                                                                ,0xFFFFFF
                                                                                ,true);
                                           date = new Date();
                                           tf.text = date.getFullYear() + "/" + (date.getMonth()+1) + "/" + date.getDate()+ "\n" +
                                                     date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();

                                           tf.autoSize = TextFieldAutoSize.LEFT;
                                           curtain.moveGrad(0xFFFFFF * Math.random(),date.getSeconds()%3);
                                           });
           timer.start();
        }
    }
}

    import flash.display.Sprite;
    import flash.geom.Matrix;
    import flash.events.Event;
    class Curtain extends Sprite{
     private var w:int;//グラデ幅
     private var matrix:Matrix = new Matrix();
     private var afColor:int;
     private var bfColor:int;
     
     private var gradRagi:int;
     
     public function Curtain():void{}
     
     public function moveGrad(_bfColor:int   //前の色
                             ,_direction:int //グラデする方向
                              ):void{
        switch(_direction){
          case 0: 
             gradRagi = 0;
             break;
          case 1:  
             gradRagi= 45;
             break;
          case 2: 
             gradRagi = 90;
             break;
          }
        afColor = 0xFFFFFF * Math.random();
        w = 0;
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
     }
     
     private function onEnterFrame(e:Event):void{
       matrix.createGradientBox(w*2,w*2,gradRagi * Math.PI / 180);
       graphics.beginGradientFill("linear", [afColor, bfColor], [1.0, 1.0], [128, 128], matrix);
       graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
       graphics.endFill();
       //この終了条件がメタメタなせいで中途半端な角度を指定できない。
       if (w >= stage.stageWidth){
         removeEventListener(Event.ENTER_FRAME,onEnterFrame);
         bfColor = afColor;
       }
       w +=20;
     }
     
    }