- 2008年3月20日 01:24
- flash
AS2.0用流れるドットテキスト(?)のソースコード。
FLASH8以上なら、1frame目にまんまコピペで実行できます。
ステージサイズはW220 x H120。
import flash.display.BitmapData;
var mc :MovieClip = _root.createEmptyMovieClip( "m", 0 );
mc._xscale = mc._yscale = 400;
var tf :TextField = _root.createTextField( "t", 1, 0, 0, 0, 0 );
tf.autoSize = "left";
tf._visible = false;
var tf2 :TextField = _root.createTextField( "t2", 2, 10, 80, 200, 20 );
with(tf2){
type = "input";
text = "hello world !";
border = true;
}
var format :TextFormat = new TextFormat();
with(format){
size = 12;
bold = true;
letterSpacing = 1;
}
tf2.setTextFormat( format );
tf2.onChanged = function ( ) {
func_init();
}
function func_init ( ) {
tf.text = " "+tf2.text;
tf.setTextFormat( format );
if ( bmd != undefined ) bmd.dispose();
var bmd :BitmapData = new BitmapData( tf._width, 100, true, 0xffffff );
mc.attachBitmap( bmd, 0 );
bmd.draw( tf );
}
mc.onEnterFrame = function() {
mc._x -= 5;
if ( mc._x+mc._width<=0 ) mc._x=Stage.width;
}
func_init();
枠内に任意のテキストを入力することで、流れる文字を変更できます。
- Newer: .JSFL : swap instance
- Older: lifegame