Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- as3
- 집합의 연산
- flash
- MMOKit
- KGC 2013
- 애드온
- scaleform3
- 스케일폼
- 플래시
- flash player 10
- GDC
- Document Class
- CLIK
- scaleform4
- Chart
- 강좌
- autodesk
- 태그클라우드
- DataBinding
- 수학정석
- 형변환
- scaleform
- as2
- flash cs3
- 클릭
- watch
- 샌프란시스코
- as3.0
- ApplicationDomain
- addChild
Archives
- Today
- Total
scaleform.minarto.com
텍스트 필드의 진실 본문
실로 오랜만의 포스팅.... 먹고 살기 바쁘다 보니...
회사 녀석이 물어본 볼드체(또는 이탤릭체) 끝이 잘려버리는 현상을 설명해주기 위해 만든 테스트 코드...
var textFormat:TextFormat = new TextFormat("굴림", 12, 0, false, true);
var txt:TextField = new TextField();
addChild(txt);
txt.border = true;
txt.text = "DSfasfsaf";
txt.autoSize = TextFieldAutoSize.LEFT;
txt.setTextFormat(textFormat);
graphics.lineStyle(1, 0, .2)
graphics.drawRect(txt.x + (txt.width - txt.textWidth) / 2, txt.y + (txt.height - txt.textHeight) / 2, txt.textWidth, txt.textHeight)
trace(txt.height, txt.textHeight)
txt = new TextField();
addChild(txt);
txt.y = 20;
txt.text = "DSfasfsaf";
txt.setTextFormat(textFormat);
txt.autoSize = TextFieldAutoSize.LEFT;
txt.border = true;
trace(txt.width, txt.height)
txt.autoSize = TextFieldAutoSize.NONE;
trace(txt.width, txt.height)
txt.width += (txt.width - txt.textWidth) / 2;
txt.height += (txt.height - txt.textHeight) / 2;
graphics.lineStyle(1, 0, .2)
graphics.drawRect(txt.x + (txt.width - txt.textWidth) / 2, txt.y + (txt.height - txt.textHeight) / 2, txt.textWidth, txt.textHeight)
trace(txt.width, txt.height)
var txt:TextField = new TextField();
addChild(txt);
txt.border = true;
txt.text = "DSfasfsaf";
txt.autoSize = TextFieldAutoSize.LEFT;
txt.setTextFormat(textFormat);
graphics.lineStyle(1, 0, .2)
graphics.drawRect(txt.x + (txt.width - txt.textWidth) / 2, txt.y + (txt.height - txt.textHeight) / 2, txt.textWidth, txt.textHeight)
trace(txt.height, txt.textHeight)
txt = new TextField();
addChild(txt);
txt.y = 20;
txt.text = "DSfasfsaf";
txt.setTextFormat(textFormat);
txt.autoSize = TextFieldAutoSize.LEFT;
txt.border = true;
trace(txt.width, txt.height)
txt.autoSize = TextFieldAutoSize.NONE;
trace(txt.width, txt.height)
txt.width += (txt.width - txt.textWidth) / 2;
txt.height += (txt.height - txt.textHeight) / 2;
graphics.lineStyle(1, 0, .2)
graphics.drawRect(txt.x + (txt.width - txt.textWidth) / 2, txt.y + (txt.height - txt.textHeight) / 2, txt.textWidth, txt.textHeight)
trace(txt.width, txt.height)
생각한 것과는 다른 결과가 나올 것이다
한가지 내가 잘못 알고 있었던 것은
txt.autoSize = TextFieldAutoSize.NONE
이러면 텍스트 필드의 width, height 가 0이 될 줄 알고 있었다는 것...