flash on 2010-8-30
文字列の表示
♥0 |
Line 28 |
Modified 2010-08-30 19:06:11 |
MIT License
archived:2017-03-10 11:01:59
ActionScript3 source code
/**
* Copyright hidebo ( http://wonderfl.net/user/hidebo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pSJr
*/
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
//文字列の表示
[SWF(width=240, height=240, backgroundColor=0x111111)]
public class StringEx extends Sprite {
private var label:TextField;
//コンストラクタ
public function StringEx(){
//ラベルの生成
label = new TextField();
label.text = "hello World!"; //テキスト
label.x = 50; //X座標
label.y = 100;
label.autoSize = TextFieldAutoSize.LEFT;//オートサイズ
label.selectable = false; //選択不可
//書式の指定
var format:TextFormat = new TextFormat();
format.color = 0xFF0000;//色
format.font = "_等幅"; //フォント
format.size = 24; //文字サイズ
label.setTextFormat(format);
//ラベルの追加
addChild(label);
// event
label.addEventListener(MouseEvent.CLICK, onMouseClick);
}
private function onMouseClick(evt:MouseEvent):void {
label.x = Math.random()*200;
label.y = Math.random()*200;
}
}
}