Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

Hour 23. Managing Movie Streaming > Task: Simple Loader - Pg. 252

Managing Movie Streaming 252 You could also use this technique on parts of a long movie. For instance, this button can be on frame 50 and let the user continue only if the next 50 frames are ready. A script attached to a small movie clip can monitor the status and move the movie forward automatically when the time is right. onClipEvent(load) { _root.textDisplay = "Waiting for the next sequence to load."; _root.stop(); } onClipEvent(enterFrame) { if (_root._framesLoaded >= 100) { _root.play(); } } This is the heart of a basic loader script. However, there are more accurate ways to monitor loading than by frames. You can use the getBytesLoaded and getBytesTotal functions to find out the actual size of the file and how much has been loaded. Here is a script that sits on a movie clip in the first frame of a movie. The first frame should also have a stop() command on it. onClipEvent(enterFrame) { if (_root.getBytesLoaded() == _root.getBytesTotal()) { _root.play(); } } Because this script runs once per frame, it is constantly checking the two functions against each other. The statement becomes true the moment the movie is completely loaded. Then the play command moves the movie forward.