2012-03-16 3 views

답변

0
TextField.prototype.shrinkToFit = function(mn) 
{ 
    var fmt = this.getTextFormat(); 
    var pt = fmt.size; 
    /* add an extra few pixels to text width to be sure (there seem to be 
    some inherent margins)*/ 
    while(this.textWidth + fmt.leftMargin + fmt.rightMargin + 4 > this._width){ 
    fmt.size = --pt; 
    this.setTextFormat(fmt); 
    // break the loop if we've reached a specified minimum font size 
    if(mn != null && pt == mn) { 
     break; 
    } 
    } 
    return pt; 
}; 

사용 예제 :

this.createTextField("tf",10,20,20,200,20); 

this.tf.multiline = false; 

this.tf.wordWrap = false; 

this.tf.setNewTextFormat(new TextFormat("_sans",18)); 

this.tf.text = "Ten thousand thundering typhoons"; 

this.tf.shrinkToFit(); 
관련 문제