flash on 2010-4-13

by kihon
♥0 | Line 52 | Modified 2010-04-13 21:06:27 | MIT License
play

ActionScript3 source code

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

package
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.display.SimpleButton;
	import flash.events.MouseEvent;
 
	public class Main extends Sprite
	{
		private var tf:TextField;
		private var count:int = 0;
 
		public function Main()
		{
			var up:State = new State(0x0);
			var over:State = new State(0xFF4500);
 
			var button:SimpleButton = new SimpleButton(up, over, over, over);
			button.x = (stage.stageWidth  - button.width)  / 2;
			button.y = (stage.stageHeight - button.height) / 2;
			button.addEventListener(MouseEvent.CLICK, onMouseClick);
			addChild(button);
 
			tf = new TextField();
			tf.defaultTextFormat = new TextFormat("", 20, 0x0, true);
			tf.autoSize = "left";
			addChild(tf);
		}
 
		private function onMouseClick(event:MouseEvent):void
		{
			tf.text = "クリックされました: " + (++count) + "回目";
		}
	}
}
 
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
 
class State extends Sprite
{
	public function State(color:int)
	{
		graphics.lineStyle(2.0, color);
		graphics.beginFill(0xFFFFFF);
		graphics.drawRect(0, 0, 100, 50);
		graphics.endFill();
 
		var tf:TextField = new TextField();
		tf.defaultTextFormat = new TextFormat("_typeWriter", 20, color, true);
		tf.text = "Click";
		tf.autoSize = "left";
		tf.x = (this.width  - tf.width)  / 2;
		tf.y = (this.height - tf.height) / 2;
		tf.selectable = false;
		addChild(tf);
	}
}

Forked