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

テキスト高さ取得の正確さ

Get Adobe Flash player
by imaji_fl 25 Aug 2010
    Embed
/**
 * Copyright imaji_fl ( http://wonderfl.net/user/imaji_fl )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/CiJ5
 */

package {
    import flash.display.Graphics;
    import flash.text.TextFormat;   
    import flash.display.Sprite;
    import flash.text.TextField
    public class FlashTest extends Sprite {
        private var tS:Sprite
        private var tX:TextField
        private var tF:TextFormat
        public function FlashTest() {
            // write as3 code here..
            tS=new Sprite
            addChild(tS)
            
            tF=new TextFormat()
            tF.size=30
            
            tX=new TextField()
            tX.defaultTextFormat=tF
            tS.addChild(tX)
            
            
           tX.autoSize='left'
           tX.width=140
           tX.wordWrap=true
         
           tX.text='フォントが違っても行数から一行分の高さが正確にわりだせるのか?行数が増えると問題があるかも?'
       
            tS.x=10
            tS.y=10
            
            for(var i:int;i<tX.numLines;i++){
               
              var g:Graphics = this.graphics
              g.beginFill (0x000000, 0.1);
              g.drawRect  ( 100, tX.height/tX.numLines*i+10-2 , 200 , tX.height/tX.numLines-2)
                                              
            }
       
            
            
            
        }
        
    }
}