Controlling the Playback Speed and Direction of a Timeline
Số trang: 9
Loại file: pdf
Dung lượng: 20.93 KB
Lượt xem: 2
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Thông thường, một thời gian đóng phim trong một hướng về phía trước với tốc độ do nhà fps (khung hình / giây) thiết lập trong hộp thoại Properties Movie. Tuy nhiên, bạn có thể kiểm soát sự chỉ đạo, trong đó thời gian di chuyển cũng như tốc độ của nó bằng cách sử dụng ActionScript. Trong thực tế, bằng cách kết hợp các yếu tố kịch bản (mà điều khiển hướng) với các sự kiện onEnterFrame, bạn có thể giành quyền kiểm soát tuyệt vời hơn thời gian của dự án...
Nội dung trích xuất từ tài liệu:
Controlling the Playback Speed and Direction of a Timeline < Day Day Up >Controlling the Playback Speed and Direction of a TimelineNormally, a movies timeline plays in a forward direction at a pace dictated by the fps(frames per second) setting in the Movie Properties dialog box. However, you can controlthe direction in which the timeline moves as well as its speed by using ActionScript. Infact, by combining scripting elements (which control direction) with the onEnterFrameevent, you can gain incredible control over the projects timeline.The first two scripting elements well discuss are the nextFrame() and prevFrame()methods of the MovieClip class. You use these methods to move a timeline to the next orprevious frame by employing the following syntax:myButton_btn.onRelease = function(){ myMovieClip_mc.nextFrame();}ormyButton_btn.onRelease = function(){ myMovieClip_mc.prevFrame();}By assigning these event handlers to buttons, you can create navigation controls thatautomatically advance or rewind a timeline one frame at a time with each click of thebutton.Even more powerful is a timelines _currentframe property (a read-only property): itsvalue represents the frame number at which the playhead currently resides. For example,if the main movie is being played, the following script places the numerical value of theplayheads current frame position into a variable named whereAreWe:var whereAreWe:Number = _root._currentframe;You can also use this property in conjunction with a conditional statement to determinewhen the playhead is within a specific range of frames and make it act accordingly:_root.onEnterFrame = function() { if(this._currentframe >= 50 && _this.currentframe As the following exercise demonstrates, by using the onEnterFrame event to execute aline of script such as the one above, you can create fast forward and rewind buttons tocontrol a timelines playback. 1. Open makeMyDay3.fla. Well continue to build on the project from the preceding exercise; most of the work for this exercise focuses on the Messages section of the application. In this area are four buttons named play_btn, stop_btn, ff_btn, and rew_btn, and a graphically empty movie clip named messages_mc. The four buttons eventually will be scripted to control the messages_mc timeline. Lets take a closer look at that timeline. 2. Double-click the messages_mc movie clip instance to edit it in place. This movie clips timeline contains two layers, Sound Clips and Actions. Frame 1 of the Actions layer contains a stop() action to prevent the timeline from moving forward until we instruct it to do so. The Sound Clips layer has a series of streaming sound clips that stretches across 700 frames. (Dragging the playhead plays the various clips.) In this exercise, well set up the buttons on the main timeline that the user can employ to navigate this timeline forward and backward. 3. Return to the main timeline. With the Actions panel open, select Frame 1 of the Actions layer and add the following script at the end of the current script: 4. 5. var fastSound:Sound = new Sound(messages_mc); 6. 7. function handleMessages(action:String){ 8. 9. } 10. The first line of the script creates a Sound object named fastSound. This Sound object eventually will be scripted to play a fast-forwarding sound when the messages_mc timeline is fast-forwarded or rewound. The remaining lines of the script are the beginnings of the handleMessages() function. This function accepts a single parameter named action, which contains a string value of play, stop, ff, or rew. This parameter value tells the function whether it should play, stop, fast-forward, or rewind the messages_mc timeline. As well describe shortly, this function will be called and passed various parameter values when you interact with one of the playback control buttons.4. Insert the following conditional statement within the handleMessage() function definition:5.6. if(action == play){7.8. fastSound.stop()9.10. delete messages_mc.onEnterFrame;11.12. messages_mc.play();13.14. }else if(action == stop){15.16. fastSound.stop();17.18. delete messages_mc.onEnterFrame;19.20. messages_mc.stop();21.22. }else{23.24. fastSound.attachSound(rewind);25.26. fastSound.start(0, 50);27.28. if(action == ff){29.30. messages_mc.onEnterFrame = function(){31.32. this.gotoAndStop(this._currentframe + 3);33.34. }35.36. }else{37.38. messages_mc.onEnterFrame = function(){39.40. this.gotoAndStop (this._currentframe - 10);41.42. }43.44. }45.46. }47.Before we discuss how the first part of the conditional statement works, youshould be aware of two events that occur later in the statement when the functionis passed a value of ff or rew. In either of those circumstances, a fast-forwarding sound is attached to the fastSound Sound object and played, and thefunctionality for carrying out either the fast-forwarding or rewinding of themessages_mc timeline is accomplished via an onEnterFrame that gets attached tothe messages_mc instance. With that in mind, lets look at the conditionalstatement one section at a time.If the handleMessages() function is passed a value of play, the first part of thisconditional statement is executed. It uses the stop() method of the Sound class totell the fastSound Sound object to quit playing, deletes the onEnterFrame eventhandler from the messages_mc movie clip instance (to prevent that timeline fromcontinuing to fast-forward or rewind), and tells the messages_mc instance toplay().If the function is passed a value of stop, the second part of the conditionalstatement is executed. This part of the statement does almost the same thing as the ...
Nội dung trích xuất từ tài liệu:
Controlling the Playback Speed and Direction of a Timeline < Day Day Up >Controlling the Playback Speed and Direction of a TimelineNormally, a movies timeline plays in a forward direction at a pace dictated by the fps(frames per second) setting in the Movie Properties dialog box. However, you can controlthe direction in which the timeline moves as well as its speed by using ActionScript. Infact, by combining scripting elements (which control direction) with the onEnterFrameevent, you can gain incredible control over the projects timeline.The first two scripting elements well discuss are the nextFrame() and prevFrame()methods of the MovieClip class. You use these methods to move a timeline to the next orprevious frame by employing the following syntax:myButton_btn.onRelease = function(){ myMovieClip_mc.nextFrame();}ormyButton_btn.onRelease = function(){ myMovieClip_mc.prevFrame();}By assigning these event handlers to buttons, you can create navigation controls thatautomatically advance or rewind a timeline one frame at a time with each click of thebutton.Even more powerful is a timelines _currentframe property (a read-only property): itsvalue represents the frame number at which the playhead currently resides. For example,if the main movie is being played, the following script places the numerical value of theplayheads current frame position into a variable named whereAreWe:var whereAreWe:Number = _root._currentframe;You can also use this property in conjunction with a conditional statement to determinewhen the playhead is within a specific range of frames and make it act accordingly:_root.onEnterFrame = function() { if(this._currentframe >= 50 && _this.currentframe As the following exercise demonstrates, by using the onEnterFrame event to execute aline of script such as the one above, you can create fast forward and rewind buttons tocontrol a timelines playback. 1. Open makeMyDay3.fla. Well continue to build on the project from the preceding exercise; most of the work for this exercise focuses on the Messages section of the application. In this area are four buttons named play_btn, stop_btn, ff_btn, and rew_btn, and a graphically empty movie clip named messages_mc. The four buttons eventually will be scripted to control the messages_mc timeline. Lets take a closer look at that timeline. 2. Double-click the messages_mc movie clip instance to edit it in place. This movie clips timeline contains two layers, Sound Clips and Actions. Frame 1 of the Actions layer contains a stop() action to prevent the timeline from moving forward until we instruct it to do so. The Sound Clips layer has a series of streaming sound clips that stretches across 700 frames. (Dragging the playhead plays the various clips.) In this exercise, well set up the buttons on the main timeline that the user can employ to navigate this timeline forward and backward. 3. Return to the main timeline. With the Actions panel open, select Frame 1 of the Actions layer and add the following script at the end of the current script: 4. 5. var fastSound:Sound = new Sound(messages_mc); 6. 7. function handleMessages(action:String){ 8. 9. } 10. The first line of the script creates a Sound object named fastSound. This Sound object eventually will be scripted to play a fast-forwarding sound when the messages_mc timeline is fast-forwarded or rewound. The remaining lines of the script are the beginnings of the handleMessages() function. This function accepts a single parameter named action, which contains a string value of play, stop, ff, or rew. This parameter value tells the function whether it should play, stop, fast-forward, or rewind the messages_mc timeline. As well describe shortly, this function will be called and passed various parameter values when you interact with one of the playback control buttons.4. Insert the following conditional statement within the handleMessage() function definition:5.6. if(action == play){7.8. fastSound.stop()9.10. delete messages_mc.onEnterFrame;11.12. messages_mc.play();13.14. }else if(action == stop){15.16. fastSound.stop();17.18. delete messages_mc.onEnterFrame;19.20. messages_mc.stop();21.22. }else{23.24. fastSound.attachSound(rewind);25.26. fastSound.start(0, 50);27.28. if(action == ff){29.30. messages_mc.onEnterFrame = function(){31.32. this.gotoAndStop(this._currentframe + 3);33.34. }35.36. }else{37.38. messages_mc.onEnterFrame = function(){39.40. this.gotoAndStop (this._currentframe - 10);41.42. }43.44. }45.46. }47.Before we discuss how the first part of the conditional statement works, youshould be aware of two events that occur later in the statement when the functionis passed a value of ff or rew. In either of those circumstances, a fast-forwarding sound is attached to the fastSound Sound object and played, and thefunctionality for carrying out either the fast-forwarding or rewinding of themessages_mc timeline is accomplished via an onEnterFrame that gets attached tothe messages_mc instance. With that in mind, lets look at the conditionalstatement one section at a time.If the handleMessages() function is passed a value of play, the first part of thisconditional statement is executed. It uses the stop() method of the Sound class totell the fastSound Sound object to quit playing, deletes the onEnterFrame eventhandler from the messages_mc movie clip instance (to prevent that timeline fromcontinuing to fast-forward or rewind), and tells the messages_mc instance toplay().If the function is passed a value of stop, the second part of the conditionalstatement is executed. This part of the statement does almost the same thing as the ...
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLGợi ý tài liệu liên quan:
-
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 263 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 251 1 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 244 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 244 0 0 -
47 trang 237 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 234 0 0 -
80 trang 215 0 0
-
122 trang 212 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 209 0 0 -
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 200 0 0