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

color clock

色を覚えたら時間が分かる
配列をうまいことして、覚えたい色を配置して・・・・
みたいなことを考えてみる
Get Adobe Flash player
by gaina 10 Apr 2010
    Embed
/**
 * Copyright gaina ( http://wonderfl.net/user/gaina )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dddT
 */

//色を覚えたら時間が分かる
//配列をうまいことして、覚えたい色を配置して・・・・
//みたいなことを考えてみる

package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.geom.ColorTransform;
	import flash.media.Sound;
	import flash.media.SoundLoaderContext;
	import flash.net.URLRequest;
	import flash.utils.Timer;
	/**
	 * ...
	 * @author gaina
	 */
        
        [SWF(width=465,height=465,backgroundColor=0xFFFFFF)]
	public class myClock extends Sprite
	{
		private var date:Date;
		private var hour:Number ;
		private var minute:Number ;
		private var second:Number ;
		private var Hsp:Sprite;
		private var Msp:Sprite;
		private var Ssp:Sprite;
		private var timer:Timer ;
		private var arr:Array = [];
		private var snd:Sound;
		
		public function myClock() 
		{
			arr = colorArr();
			
			Ssp = DRrect();
			Ssp.x = stage.stageWidth -  Ssp.width;
			addChild(Ssp);
			
			Msp = DRrect();
			Msp.x = stage.stageWidth - stage.stageWidth / 2 - Msp.width / 2;
			addChild(Msp);
			
			Hsp = DRrect();
			Hsp.x = 0;
			addChild(Hsp);
			
			snd = new Sound();
			var context:SoundLoaderContext = new SoundLoaderContext(1000);
			var req:URLRequest = new URLRequest("http://www.takasumi-nagai.com/soundfiles/pi.mp3");
			snd.load(req,context);

			timer = new Timer(1000);
			timer.addEventListener(TimerEvent.TIMER, loop);
			timer.start();
		}
		private function loop(event:TimerEvent):void {			
			date = new Date();
			second = date.getSeconds();
			var sCt:ColorTransform = new ColorTransform();
			sCt.color = arr[second];
			minute = date.getMinutes();
			var mCt:ColorTransform = new ColorTransform();
			mCt.color = arr[minute];
			hour = date.getHours();
			var hCt:ColorTransform = new ColorTransform();
			hCt.color = arr[hour];
			Ssp.transform.colorTransform = sCt;
			Msp.transform.colorTransform = mCt;
			Hsp.transform.colorTransform = hCt;
			
			//Ssp.scaleY = second / 60;
			//Msp.scaleY = minute / 60;
			//Hsp.scaleY = hour / 24;
			
			snd.play(0, 1);
		}
		
		private function DRrect(xx:Number = 0, yy:Number = 0, w:Number=100, h:Number=100):Sprite {
			w = stage.stageWidth / 3;
			h = stage.stageHeight;
			var sp:Sprite = new Sprite();
			sp.graphics.beginFill(0);
			sp.graphics.drawRect(xx, yy, w, h);
			sp.graphics.endFill();
			return sp;
		}
		
		private function colorArr():Array {
			var ar:Array = [];
			ar = [0x33CCFF,0x33CCCC,0x33CC99,0x33CC66,0x33CC33,0x33CC00,0x00CCFF,0x00CCCC,0x00CC99,0x00CC66,
                              0x00CC33,0x00CC00,0x3399FF,0x3399CC,0x339999,0x339966,0x339933,0x339900,0x0099FF,0x0099CC,
                              0x009999,0x009966,0x009933,0x009900,0x3366FF,0x3366CC,0x336699,0x336666,0x336633,0x336600,
                              0x0066FF,0x0066CC,0x006699,0x006666,0x006633,0x006600,0x3333FF,0x3333CC,0x333399,0x333366,
                              0x333333,0x333300,0x3300FF,0x3300CC,0x330099,0x330066,0x330033,0x330000,0x0033FF,0x0033CC,
                              0x003399,0x003366,0x003333,0x003300,0x0000FF,0x0000CC,0x000099,0x000066,0x000033,0x000000
                              ];
			return ar;
		}
	}
}