flash on 2010-1-4

by yama3
♥0 | Line 35 | Modified 2010-01-04 00:37:10 | MIT License
play

ActionScript3 source code

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

package {
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.events.MouseEvent;
	
	public class MyTextField extends Sprite {
		public var fld:TextField;
		
		public function MyTextField() {
			fld = new TextField();
			fld.x = 50;
			fld.y = 50;
			fld.autoSize = TextFieldAutoSize.LEFT;
			fld.background = true;
			fld.backgroundColor = 0xffffff;
			
			var tf:TextFormat = new TextFormat();
			tf.font = "_typewriter";
			tf.size = 18;
			fld.defaultTextFormat = tf;
			fld.text = "楽しいActionScriptの世界へ";
			addChild(fld);
			fld.selectable = false;
			fld.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
			fld.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
		}
		public function rollOverHandler(event:MouseEvent):void {
			fld.textColor = 0xFFFFFF;
			fld.backgroundColor = 0x009900;
		}
		public function rollOutHandler(event:MouseEvent):void {
			fld.textColor = 0x000000;
			fld.backgroundColor = 0xffffff;
		}
	}
}