2: 2015-06-08 (月) 11:43:54 njf |
現: 2018-04-14 (土) 01:59:27 njf |
| StarlingのTextFieldを使うとAS3と同様にしてテキストを表示できる。 | | StarlingのTextFieldを使うとAS3と同様にしてテキストを表示できる。 |
| + | |
| + | (&font(Red){以下の内容はver1.xのみに対応しています。ver.2以降からTextFieldは大幅に変更されました};) |
| | | |
| var tf:TextField = new TextField(200, 30, "test",FONT_NAME,26,0xff0000); | | var tf:TextField = new TextField(200, 30, "test",FONT_NAME,26,0xff0000); |
| 二つ目は、パフォーマンスが必要とされるところではなるべくビットマップフォントを指定し、文字数が少ない場合はbatchableフラグをtrueにすると結構減る | | 二つ目は、パフォーマンスが必要とされるところではなるべくビットマップフォントを指定し、文字数が少ない場合はbatchableフラグをtrueにすると結構減る |
| | | |
- | tf.batchable = true; | + | tf.batchable = true; |
| | | |
| 3つめについては、たとえば複数行表示で行間を8にしたければ、TextFieldを継承して、formatTextメソッドをオーバーライドする。 | | 3つめについては、たとえば複数行表示で行間を8にしたければ、TextFieldを継承して、formatTextメソッドをオーバーライドする。 |
| public function MultiLineTextField (width:int, height:int, text:String, fontName:String = "Verdana", fontSize:Number = 12, color:uint = 0, bold:Boolean = false) { | | public function MultiLineTextField (width:int, height:int, text:String, fontName:String = "Verdana", fontSize:Number = 12, color:uint = 0, bold:Boolean = false) { |
| super(width, height, text, fontName, fontSize, color, bold); | | super(width, height, text, fontName, fontSize, color, bold); |
| + | |
| } | | } |
| override protected function formatText(textField:flash.text.TextField, textFormat:TextFormat):void | | override protected function formatText(textField:flash.text.TextField, textFormat:TextFormat):void |