Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
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. flash.display.MovieClip nhập khẩu, flash.text 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 flash.display.MovieClip import flash.text. 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.name tf tf.mouseEnabled false tf.x this.x tf.y this.y tf.width this.width tf.height this.height tf.wordWrap false tf.multiline false tf.textColor 0x000000 tf.htmlText TextField We also add the line this.addChild 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 this.addChild tf We further create a default text format which determines basic properties of the text field var format TextFormat new TextFormat format.align center format.font Arial format.size 12 tf.defaultTextFormat 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 tf.htmlText