テキスト高さ取得の正確さ
/**
* 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)
}
}
}
}