• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Hour 23. Managing Movie Streaming > Task: Simple Loader

Task: Simple Loader

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

Start with a blank movie.

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.

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.

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) {

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.

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

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.

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.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint