Đang chuẩn bị liên kết để tải về tài liệu:
Học Actionscript 3.0 - p 14
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
A Simple Site or Application Structure 1 2 3 4 5 6 7 8 9 10 11 12 var nextSection:String = ""; section1.addEventListener(MouseEvent.CLICK, navigate, false, 0, true); section2.addEventListener(MouseEvent.CLICK, navigate, false, 0, true); section3.addEventListener(MouseEvent.CLICK, navigate, false, 0, true); function navigate(evt:MouseEvent):void { nextSection = evt.target.name; play(); } The remainder of the script is similar to the previous examples, creating three buttons that all access the same listener. Line 10 populates the nextSection variable using the name of the button that was clicked. Knowing that the target property can identify the button that was clicked, we can further query its name property to determine the name of the button. By naming buttons with names that match frame labels, we can set up. | A Simple Site or Application Structure I var nextSection String 2 3 section1.addEventListener MouseEvent.CLICK navigate 4 false 0 true 5 section2.addEventListener MouseEvent.CLICK navigate 6 false 0 true 7 section3.addEventListener MouseEvent.CLICK navigate 8 false 0 true 9 function navigate evt MouseEvent void 10 nextSection evt.target.name II piay 12 The remainder of the script is similar to the previous examples creating three buttons that all access the same listener. Line 10 populates the nextSection variable using the name of the button that was clicked. Knowing that the target property can identify the button that was clicked we can further query its name property to determine the name of the button. By naming buttons with names that match frame labels we can set up our file cleanly and efficiently Clicking the sectionl button will take us to the corresponding section1 frame label. How then do we prevent the entry and exit animations from being interrupted or from overlapping First each button click populates the nextSection variable with the desired destination frame label. Then we use play to play the file from that point forward. This plays through the entry animation of the first section and then another script halts the playhead in the content keyframe of the section with a stop action. at end of entry animation stop Using the play method prevents repeated clicks on a button from starting an entry animation over and over again a possible side effect of using gotoAndPlay . Instead of every click first jumping to a specific frame before playing each click just continues to tell the timeline to play which it s already doing and so has no ill effect. Having stopped at the content frame of the section the user is free to view that screen. Any subsequent button clicks will first populate the nextSection variable and then again call the play method. This sets the playhead in motion carrying it through the concluding animation until it hits the last frame .