TAILIEUCHUNG - Học Actionscript 3.0 - p 30

Formatting Text Using the first line, the extra word, “new” will be red, bold, and underlined because that’s the format when the text was added. Commenting out line 27 and using line 28, however, will remove all the red, bold, underline formatting from the field because the field will revert to its default format. N OT E As a nicety, Flash Professional will warn you that using the compound assignment operator (+=) is slower than using the appendText() method. Tab Stops Another handy feature made possible by the TextFormat class is tab stops. If you find formatting text columns difficult using the Flash Professional interface,. | Formatting Text Using the first line the extra word new will be red bold and underlined because that s the format when the text was added. Commenting out line 27 and using line 28 however will remove all the red bold underline formatting from the field because the field will revert to its default format. Tab Stops Another handy feature made possible by the TextFormat class is tab stops. If you find formatting text columns difficult using the Flash Professional interface you ll be relieved to find how easy it can be to create simple columns with tab stops using ActionScript. The next example uses the TextFormat class to set two tab stops so that text including tab characters will line up at these stops forming columns. See file to try this yourself. Let s get to the code. The first 13 lines of this script include only previously discussed material creating and configuring TextFormat and TextField objects. We didn t include the tab stops in the format initially because we want to show you how to edit and use a TextFormat object after it s been created. Take a look at the setup first and then we ll discuss the application of the tab stops 1 var txtFmt TextFormat new TextFormat 2 _sans 3 10 4 4 5 6 6 7 var txtFld TextField new TextField 8 20 9 400 10 11 true 12 true 13 txtFmt Lines 14 through 17 populate the field txtFld which you just set up in lines 7 through 13. Notice the inclusion of the t escape character in line 15. Its backslash prevents this character from being understood as the letter t. Instead it s interpreted as a tab. Another escape character n appears in line 16. In this case the n is a new line character moving the new text insert point down to the next line in the field. Therefore each time through the

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.