Sams Teach Yourself Macromedia Flash 8 in 24 Hours
< Day Day Up > |
The Workshop consists of quiz questions and answers to help you solidify your understanding of the material covered in this hour. You should try to answer the questions before checking the answers. Quiz
Quiz Answers
Exercise
Back in the task "Use the MovieClipLoader Object to Display Progress," you displayed a progress bar by scaling from 0% to 100%. Instead, for this exercise, consider making a movie clip containing an animation. For example, you could do a shape tween or frame-by-frame animation of a glass filling up or a sand-timer emptying. The code really isn't too difficult. Instead of taking the percentage downloaded and setting the _xscale, you just do a gotoAndStop(). Imagine if the movie clip you create has 100 frames; you could simply jump to the frame that matches the percentage. In fact, you can jump only to whole number frames when using gotoAndStop(). The following code takes care of that. What's cool about this code is that your movie clip need not be exactly 100 frames. So, make a movie clip with the multiple frame animation you want and put an instance on stage with the instance name progress_mc. Then, replace line 7 of step 7 of the task "Use the MovieClipLoader Object to Display Progress" with the following code: progress_mc.gotoAndStop( Math.floor((bytesLoaded/bytesTotal) * progress_mc._totalframes ));
|
< Day Day Up > |