반응형
Flex에서 UITextField를 사용할때.
해당 TextField의 속성을 정하는 방법은 여러가지가 있다.
setStyle을 이용해서 할수도 있지만.
해당 글자중 부분만 적용하고자 할경우에는 TextFormat을 이용해서 할수가 있다.
-실행 화면-
위의 소스 코드를 보면 간단하다.
UITextFiled를 UIComponent에 붙여 주고
붙은 UIComponent를 _component에 붙여 주었다. (_component는 실제 제가 화면에 나타내주는 UIComponent 이다. 이렇게 이중 작업하시지 않게 _component 에 붙이시지 않고 tUI를 바로 화면에 나타나게 붙여도 됩니다.)
핵심은
var tFormat:UITextFormat = tText.getUITextFormat();
textFormat을 가져온다.
그리고
tFormat.size = 30;
tFormat.italic = true;
설정을 할수 있다.
마지막으로 가장 중요한. settText.setTextFormat(tFormat);
setTextFormat을 하면서 text Index를 줄수 있다. parameter를 총 3개 넘길수 있는데.
* TextFormat, begin index, end Index를 넘길수 있다.
더 중요한것은 해당 TextFiled를 붙일곳에 붙인 이후에 해당 속성을 변경하여 set 해주어야 한다.
(즉, Format을 set 한다음 addChild로 해당 TextFiled를 다른곳에 붙이면 속성이 먹지 않는다.)
해당 TextField의 속성을 정하는 방법은 여러가지가 있다.
setStyle을 이용해서 할수도 있지만.
해당 글자중 부분만 적용하고자 할경우에는 TextFormat을 이용해서 할수가 있다.
// UI TextFiled sample code public function drawText():void{ var tUI:UIComponent = new UIComponent(); var tText:UITextField = new UITextField(); tText.text = "우헤헤"; tUI.addChild(tText); _component.addChild(tText); var tFormat:UITextFormat = tText.getUITextFormat(); tFormat.size = 30; tFormat.italic = true; tText.setTextFormat(tFormat); }
-실행 화면-
위의 소스 코드를 보면 간단하다.
UITextFiled를 UIComponent에 붙여 주고
붙은 UIComponent를 _component에 붙여 주었다. (_component는 실제 제가 화면에 나타내주는 UIComponent 이다. 이렇게 이중 작업하시지 않게 _component 에 붙이시지 않고 tUI를 바로 화면에 나타나게 붙여도 됩니다.)
핵심은
var tFormat:UITextFormat = tText.getUITextFormat();
textFormat을 가져온다.
그리고
tFormat.size = 30;
tFormat.italic = true;
설정을 할수 있다.
마지막으로 가장 중요한. settText.setTextFormat(tFormat);
setTextFormat을 하면서 text Index를 줄수 있다. parameter를 총 3개 넘길수 있는데.
* TextFormat, begin index, end Index를 넘길수 있다.
더 중요한것은 해당 TextFiled를 붙일곳에 붙인 이후에 해당 속성을 변경하여 set 해주어야 한다.
↓
왜 냐하면 addChild 되는 순간에 해당 컴포넌트의 invalidateProperties(), commitProperties() 가 호출되기 때문에 적용이 되지 않는다. (즉, Format을 set 한다음 addChild로 해당 TextFiled를 다른곳에 붙이면 속성이 먹지 않는다.)
반응형