traning-004

by ketatony
♥0 | Line 35 | Modified 2010-04-08 00:34:02 | MIT License
play

ActionScript3 source code

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

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 = "花は盛りに、月は隈なきをのみ、見るものかは";
			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;
		}
	}
}