tailieunhanh - Flash XML Applications Use AS2 and AS3 to Create Photo Galleries, Menus, and Databases phần 10

Chúng tôi nhập khẩu các lớp MovieClip và cho các lớp văn bản chúng tôi hiện đang sử dụng một ký tự đại diện. Chúng tôi tuyên bố chỉ có một biến, "tf", TextField kiểu dữ liệu. nhập khẩu, nhập khẩu . | Flash XML Applications It is time to see what the ButText class looks like. Basically it is a script that creates a text field with formatting. Then there are a number of getters and setters which are needed to change the text format of the text field once it has been created. We import the MovieClip class and for the text classes we currently use a wildcard. We declare only one variable tf of data type TextField. import import . public class ButText extends MovieClip private var tf TextField public function ButText In the constructor we place a script to create a new text field with various properties like x and y coordinates width and so on. We disable any mouse reaction of the text field tf new TextField tf false false false 0x000000 TextField We also add the line tf . The this word would refer to the object that is calling the ButText class for example the EventButton class which extends the ButText class. The text field would then be placed on the EventButton instance tf We further create a default text format which determines basic properties of the text field var format TextFormat new TextFormat center Arial 12 format To make this class more versatile and be able to change properties at runtime when the text field is already created we add getter and setter methods for changing the text field content x y width height wordwrap multiline color and some other properties of the text field and associated text. Chapter 19 The Search Engine Part 1 28 This allows adding button behavior to text in a text field such as italic bold and or color change to mention a few examples. I have listed only two examples here for getters and setters for the label . public function set tf_label t_label String void

TỪ KHÓA LIÊN QUAN