Tracking Playback and Downloading Progression

Tracking Playback and Downloading Progression

Lượt xem: 22,604Lượt tải: 10Số trang: 7

Mô tả tài liệu

Theo dõi Playback và tải về Thăng Tiến Số lượng khung hình trong một bộ phim và kích thước tập tin nội dung xác định chiều dài tổng thể của bộ phim và kích thước thực tế-a làm rõ bằng cách nhìn vào chính thời gian mà các yếu tố này đại diện cho chiều dài và kích thước của các SWF toàn bộ.

Tóm tắt nội dung

< Day Day Up > Tracking Playback and The number of frames in a movie and the file size of their contents determine the movie's overall length and size—a fact made evident by looking at the main timeline where these factors represent the length and size of the entire SWF. The total number of frames in a movie is a by property. If the main timeline has 400 frames that span several scenes, the following script sets the value of to 400: var = You can use this property in scripts to determine the overall length of the movie (based in frames). NOTE Because it's a read-only property, the value of is set by Flash (based on the number of frames on a Not only does it not make sense to attempt to reset this not even possible! If you know the value of you can use it in with other movie to make during and playback. For example, by the value of the property with the value of the you can determine how much longer the movie will play: var = - = "There are " + + " to go."; Because Flash is based on streaming the process of and viewing an SWF from a Web site actually occurs one frame at a time. Another property, provides the total number of frames that have been The value of this property can be compared to the property to provide about the progress of the download. In the following exercise, we'll this principle by creating a progress bar (known as a that shows the of frames that have been 1. Open in the folder. This project contains two scenes: Preloader and Content. The Content scene simply contains several layers of graphics and animation that how the works. The Content scene also contains a frame label named Start that plays an important role in the end result of the project. All of our work in this exercise takes place in the Preloader scene, which contains three layers: and Actions. The layer contains a square with a radial gradient. The Actions layer contains a stop() action to prevent the timeline from moving forward until we instruct it to do so. The Preloader scene contains two text label the text "now loading…" and a movie clip instance named which includes the elements that show the progress. We'll add script to this timeline, so let's take a closer look at it. 2. the movie clip instance to edit it in place. This movie clip's timeline consists of four layers named according to their The most important aspects of this timeline are the text field named which resides on the Text layer, and the tweened animation on the Amount layer. The text field displays the of frames that have The tweened animation a 100-frame progress bar that begins at 0 percent and ends at 100 percent. Among other things, our script moves this movie's timeline to the frame number based on the of frames that have been and the progress bar moves 3. With the Actions panel open, select Frame 1 of the Actions layer and add the script: 4. 5. stop(); 6. 7. = { 8. 9. var = (( / * 100)); 10. 11. 12. 13. = + "% 14. 15. if >= 90) { 16. 17. 18. 19. } 20. 21. } 22. The first action prevents the timeline from moving forward until we tell it to do so. The second line attaches an event handler to the preloader clip. As a result, the script within the event handler is executed 24 times a second, which means that it instantly reacts to the current to display the most accurate of the process. This script a value for the number of frames that have It then rounds up that number and assigns the resulting value to the variable. Using the employed to do this work is evaluated in the following manner: With this part of the the number of frames on the main timeline that have loaded is divided by the total number of frames on the main timeline. NOTE Because this script is within the preloader movie clip instance and the instance resides on the main timeline, the use of _parent as the target path is a reference to the main timeline. This setup allows the preloader clip to be used (and function without in any project. For purposes, let's assume that the movie has 735 frames, 259 of which have loaded. The would look like this: 259 / 735 This would result in a value of .3523. The next part of the that result by 100: * 100 This would result in a value of 35.23. Finally, using the method, this value is rounded up to the next whole number, 36—and thus is assigned a value of 36. Remember that because this script is executed 24 times per second, the value of increases as the movie is TIP The and used in this script can be replaced with the and methods of the MovieClip class if you want to make this preloader react to bytes loaded (rather than just frames). This is sometimes the preferred method of scripting a preloader because a frame is not loaded (and thus the preloader doesn't advance) until all the data that it contains is loaded. The preloader may appear stalled if the frames loaded contain numerous bytes of data. In contrast, looking at the bytes loaded causes the to move forward more smoothly because changes in byte data happen more (as each byte of data is See the bonus file on the CD that this The next action in the script sends the preloader instance to the frame, based on the value of Because the current movie contains the tweened animation of the progress bar moving from left to right, this action controls the movement of that bar. As the value of so does the of progress on the progress bar. The next action sets what's displayed in the info_txt text field. Here, the value of is with the string "% If has a value of 36, for example, the result is "36% The last part of the script contains a statement used to determine when the work is complete. It says that when the value of is equal to or more than 90, the main timeline should be moved to the frame labeled Start and played from there. NOTE The value of 90 in this statement could easily be changed to any value to specify when the work is finished and the movie can begin to play. 4. Choose Control > Test Movie to view the project to this point. When the test movie appears, choose View > Download Settings > 56K; then choose View > Simulate Download. This setting provides a fairly accurate of how the preloader will look and function when the movie is being over a 56K modem. As the movie loads, the of the movie changes The progress bar reflects the ongoing status of the process. As explained in Step 3, after 90 percent of the movie's frames have the timeline moves to the Content scene and the movie plays from there. 5. Close the test movie and save the project as This step completes the exercise and this lesson. < Day Day Up >