テキストエリアにあわせてフォントサイズを変更する matsu forked:1favorite:6lines:30license : MIT License modified : 2010-02-19 12:52:16 Embed Tweet <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" applicationComplete="appComplete();"> <mx:Script> <![CDATA[ [Bindable] private var _maxFontSize:uint = 20; private var _tempFontSize:uint = 0; private function appComplete():void { start(); } public function start():void { _tempFontSize = _maxFontSize; var testStr:String = "あいうえおかきくけこさしすせそたちつてとなにぬねのあいうえおかきくけこさしすせそたちつてとなにぬねの"; aaaText.text = bbbText.text = testStr; } private function bbbTextUpdateComplete(evt:Event):void { bbbText.setStyle("fontSize", _tempFontSize); // 微調整で、+4 する。おそらく Text の border の top, right, bottom, left が、それぞれ 1 px ずつあるのだと思う。 if ( evt.currentTarget.textHeight + 4 > evt.currentTarget.height ) { _tempFontSize -= 1; bbbText.setStyle("fontSize", _tempFontSize); } } ]]> </mx:Script> <mx:Text id="aaaText" width="200" height="60" fontSize="{_maxFontSize}"/> <mx:Text id="bbbText" width="200" height="60" updateComplete="bbbTextUpdateComplete(event);"/> </mx:Application> Code Fullscreen Preview Fullscreen route153 siouxcitizen.. flasher_bbb beryu digitrick djakarta_tra.. : Text フォントサイズ Flex Text Text フォントサイズ sort new page view favorite forked pv406 forked from: テキストエリアにあわせてフォントサ.. Makoto_Tanaka forked:1 favorite:0lines:31 (diff:1)