flash on 2010-8-30

by hidebo
文字列の表示
♥0 | Line 28 | Modified 2010-08-30 19:06:11 | MIT License
play

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;
        }
    }
}

Forked