forked from: 虹色変化

by Nyarineko forked from 虹色変化 (diff: 24)
//////////////////////////////////////////////////////////////////////////////
虹色変化
//////////////////////////////////////////////////////////////////////////////
♥2 | Line 55 | Modified 2010-05-27 21:20:56 | MIT License
play

ActionScript3 source code

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

// forked from ProjectNya's 虹色変化
////////////////////////////////////////////////////////////////////////////////
// 虹色変化
////////////////////////////////////////////////////////////////////////////////

package {

	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import frocessing.color.ColorHSV;

	[SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]

	public class Main extends Sprite {
		private var circle:Shape;
		private var colorTrans:ColorTransform;
		private var color:ColorHSV;
		private var a:Number;
		private var b:Number;

		public function Main() {
			//Wonderfl.capture_delay(1);
			init();
		}

		private function init():void {
			graphics.beginFill(0x000000);
			graphics.drawRect(0, 0, 465, 465);
			graphics.endFill();
			circle = new Shape();
			addChild(circle);
			circle.x = 232;
			circle.y = 232;
			circle.graphics.beginFill(0x000000);
			circle.graphics.drawCircle(0, 0, 120);
			color = new ColorHSV(0, 1);
			colorTrans = new ColorTransform();
			colorTrans.color = color.value;
			circle.transform.colorTransform = colorTrans;
			addEventListener(Event.ENTER_FRAME, update, false, 0, true);
			
			a = Math.random() * 10;
			b = Math.random() * 10;
		}
		private function update(evt:Event):void {
			color.h ++;
			colorTrans.color = color.value;
			circle.transform.colorTransform = colorTrans;
			//うごかしてみよー!
			circle.x += a;
			circle.y += b;
			if(circle.x > (465 - circle.width/2)){
				a = Math.random() * -10;
			}
			if(circle.x < (0 + circle.width/2)){
				a = Math.random() * 10;
			}
			if(circle.y > (465 - circle.height/2)){
				b = Math.random() * -10;
			}
			if(circle.y < (0 + circle.height/2)){
				b = Math.random() * 10;
			}
		}
	}
}