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

forked from: TextField_scroll

Get Adobe Flash player
by mhayashi 22 Feb 2010
    Embed
/**
 * Copyright mhayashi ( http://wonderfl.net/user/mhayashi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/aW43
 */

// forked from oshige's TextField_scroll
package {
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.ui.Keyboard;
	import flash.events.KeyboardEvent;
	public class MyTextField extends Sprite {
		public var fld:TextField;
		public function MyTextField(){
			var tf:TextFormat = new TextFormat();
			tf.font = "_sans";
			tf.size = 18;
			fld = new TextField();
			fld.border = true;
			fld.width = 300;
			fld.height = 100;
			fld.multiline = true;
			fld.wordWrap = false;
			fld.defaultTextFormat = tf;
			fld.text = "a:Archie Shepp\n" + "b:Buddy Rich\n" + "c:Cannonball Adderley\n" + "d:Donny Hathaway\n" + 
			"e:Eric Dolphy\n" + "f:Frankie Paul\n" + "g:Gonzalo Rubalcaba\n" + "h:Hank Mobley";
			fld.x = 100;
			fld.y = 50;
			addChild(fld);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
		}
		//キーボードイベントでスクロールします。
		public function keyDownHandler(event:KeyboardEvent):void {
			switch (event.keyCode) {
				case Keyboard.UP :
					if (event.shiftKey) {
						//上下スクロールを先頭に戻します。
						fld.scrollV = 0;
					} else {
						//上へ1行スクロールします。
						fld.scrollV -= 1;
					}
					break;
				case Keyboard.DOWN :
					if (event.shiftKey) {
						//一番下までスクロールします。
						fld.scrollV=fld.maxScrollV;
					} else {
						//下へ1行スクロールします。
						fld.scrollV+=1;
					}
					break;
				default :
			}
		}
	}
}