Home > Articles

  • Print
  • + Share This
This chapter is from the book

Determining When a Movie Is Fully Loaded and How to Unload It

Now that you know how to load a movie, it's a good idea to learn how to unload it. But first, you should learn how to determine whether a movie that's loading has completed loading! This will be important if the movie that's loading is large. It's nice to let the user see that a movie is indeed downloading. You might actually want to make the user wait for it to fully load. All these things require you to determine whether a loading movie has downloaded.

To determine whether a movie has loaded, you can use either the two built-in properties _framesloaded and _totalframes or the two clip methods getBytesLoaded() and getBytesTotal(). You can use either pair (_framesloaded and _totalframes or getBytesLoaded() and getBytesTotal()) and if their values are the same, then you know the movie has downloaded. For example, if you're loading into a clip and you want to know how many frames have loaded, you can use theClip._framesloaded (where "theClip" is the instance name of the clip). Of course, if you write this script inside or attached to the clip itself, you don't need to precede the property with the instance name (Flash knows you must be inquiring about the _framesloaded property of that clip). Finally, _framesloaded and _totalframes only make sense when the loaded movie has several frames.

  • + Share This
  • 🔖 Save To Your Account