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

Chúng tôi đã bao gồm một số các ứng dụng này trong các chương trước, nhưng bây giờ chúng tôi sẽ đưa tất cả lại với nhau thành một ứng dụng. Vì vậy, cảm thấy như một người quản lý dự án, và tưởng tượng rằng bạn có để giám sát toàn bộ dự án. bạn sẽ | Flash XML Applications mouse events. In AS2 or AS1 if a MovieClip with button functions or a button had a child which also had button functions it was not possible to handle the event of the child. Only the event of the parent was handled. In AS3 it is now possible to separate parent from child events. Because of this there is a phenomenon known as event bubbling. That means that the event from the child bubbles to the parent. A mouse event of the child will also result in a mouse event of the parent. This can sometimes be useful and later there will be an example in which this is demonstrated. However fortunately we can also separate the events so that the parent will not listen to the child event handler. We will now get to an example which describes a button function associated with a MovieClip. We create a simple MovieClip and associate this MovieClip with the Starter_6 class when we establish linkage. We place an instance of this MovieClip on the stage but avoid naming it. The main function of this button MovieClip is to load a TextField and change the text content depending on the mouse event. We first need to import several classes among which is the class. package import import import public class Starter_6 extends MovieClip private var tField TextField public function Starter_6 In AS3 the mouse icon is not automatically shown when the cursor is over the button area. Therefore we need to signal the player that the object will have buttonMode true We create an instance of a TextField and position it. All objects are created with the new operator. Also note that properties are no longer written with an underscore for example _x . This was already introduced with Flash 8 components. tField new TextField 50 10 The TextField will be a child of the button MovieClip and will react strangely to any Mouse-over event. To prevent this

TỪ KHÓA LIÊN QUAN