文字の連続表示
♥0 |
Line 34 |
Modified 2010-07-04 23:19:53 |
MIT License
archived:2017-03-20 01:40:35
ActionScript3 source code
/**
* Copyright Makoto_Tanaka ( http://wonderfl.net/user/Makoto_Tanaka )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uUEk
*/
package {
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.display.Sprite;
public class TextTest extends Sprite {
var _textField:TextField;
var _msg:String = "Hello World";
var _timer:Timer;
public function TextTest() {
// テキストの書式
var tf:TextFormat = new TextFormat();
tf.font = "_typewriter";
tf.size = 18;
tf.color = 0x0000FF;
// テキストフィールドの作成
_textField = new TextField();
_textField.x = 100;
_textField.y = 50;
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.background = true;
_textField.backgroundColor = 0xFFFF00;
_textField.defaultTextFormat = tf;
addChild(_textField);
// Timerの設定
_timer = new Timer(100, _msg.length);
_timer.addEventListener(TimerEvent.TIMER, onTimer);
_timer.start();
}
/**
* TimerEvent
* 一文字ずつ文字を表示する
*/
private function onTimer(e:TimerEvent):void {
var char:String = _msg.charAt(_timer.currentCount-1);
_textField.appendText(char);
}
}
}