Task: Simple Loader

I l @ ve RuBoard

Here is how to build a simple loader frame that waits for the entire movie to load before continuing past frame 1:

  1. Start with a blank movie.

  2. Place a blank key frame at frame 1.

    Start a new key frame at frame 2. Play some content starting at frame 2 and continuing on. It should be at least 100K worth of content. A good way to get fast content is to import a video.

  3. Back at frame 1, we want to have the movie wait until the entire movie has been loaded before continuing to frame 2. Start by placing a stop() command on the frame.

  4. Create a simple shape, convert it to a movie clip, and move it off the screen. Assign this script to it:

     onClipEvent(enterFrame) {     bytesLoaded = _root.getBytesLoaded();     bytesTotal = _root.getBytesTotal()     percentLoaded = Math.round(100*bytesLoaded/bytesTotal);     _root.displayText = "Loading: "+percentLoaded+"%";     if (bytesLoaded == bytesTotal) {         _root.play();     } } 

    The script looks at getBytesLoaded to see whether the movie has finished loading; it uses this to also calculate the percent of the movie loaded. It places this number into the variable displayText at the root level.

  5. Create a dynamic text field and link it to the variable displayText .

  6. It will be difficult to test this movie on your hard drive because it will load too quickly. Instead, Publish it, complete with a Web page. Upload it to a test directory on your Web site.

  7. Go to the Web page with your browser. You should see its loading progress reported in the text field. When it reaches 100 percent, the movie should automatically continue.

You can compare your movie with 23simpleloader.fla.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net