1
뷰어 (도시, 주)의 위치 정보를 가져 오는 플래시 응용 프로그램을 만들었습니다. 그리고 글꼴 크기를 얼마나 크게할지에 따라 글꼴을 더 작게 만들 수 있습니다. 도시의. 예를 들어, "Detroit"는 적합 할 수 있지만 "Los Angeles"는 작은 글꼴 일 필요가 있습니다.플래시 : 단어의 크기에 따라 텍스트 크기를 변경 하시겠습니까?
뷰어 (도시, 주)의 위치 정보를 가져 오는 플래시 응용 프로그램을 만들었습니다. 그리고 글꼴 크기를 얼마나 크게할지에 따라 글꼴을 더 작게 만들 수 있습니다. 도시의. 예를 들어, "Detroit"는 적합 할 수 있지만 "Los Angeles"는 작은 글꼴 일 필요가 있습니다.플래시 : 단어의 크기에 따라 텍스트 크기를 변경 하시겠습니까?
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();