Loading Pre-loading animation program design

Source: Internet
Author: User
Tags file size time in milliseconds root directory
Loading| Program | design

We said that the flash production of multimedia Web site is the essence of Flash animation, but also the most widely used flash animation. Before Flash appeared, the website design was static and GIF animated world. Of course there are many techniques, such as Javaapplet and JavaScript. But these technologies are not widely used. Network bandwidth is also the impact of network multimedia development of a bottle path. But Flash has appeared. It brings a new meaning to the network, bring the network interactive media, make the network interactive multimedia possible, become a reality. Three years ago, when we browsed the list of foreign websites, we mainly stayed in some graphic design works, but now the list of foreign countries has a lot of interactive multimedia animation website. The speed of flash development shows. IE browser has built-in flash player player in version 6.0, which seems to be the way to develop Web site production. Let's take a taste of the glamour of interaction.

Loading Pre-loading animation program design

Loading Web page preload program is a key in web animation, because even if the flash generated a small file, but the system made large animation for the use of the modem user speed still need to be resolved. If you do not have a preload process, I am afraid that the animation will not be very smooth to watch. Especially in the animation to add a lot of sound and image of the animation without the loading will not be smooth show in front of us.
Before that, learn about the attributes and functions that will appear in this chapter. If you use a function or property that has not been contacted in an example, make it as usual, and then look back at the other related functions in later chapters, and you will fully understand the role of the example.

_framesloaded

_framesloaded is the property of a movie clip that gets the number of frames that have been downloaded in a movie clip, and of course the properties that apply to movie clips in large numbers can be applied to the entire animation. This property can be used only for fetching.
if (_root.mc._framesloaded>100) {
_root.gotoandplay (1)
}
This example is entered in normal mode to become:
if (GetProperty ("_ROOT.MC", _framesloaded) >100) {
gotoAndPlay (1)
}
Access to properties in normal mode uses the GetProperty function, but this function is not optimal in the use of the new. syntax, and is no longer referenced in the following example. In this example, when the number of frames that the movie clip has already downloaded is greater than 100, begin the return scene replay. This is also in the production of a typical example, a lot of movie clips because of the volume problem, in the "stream" playback process will not be very smooth. The following example would be an example of a mistake.
_root.mc._framesloaded=100;
_root.gotoandplay (1);
The _framesloaded attribute is not allowed to be assigned in programming, and if you want the root directory to start playing back when the number of frames you download equals 100, follow the example below.
if (_root.mc._framesloaded=100) {
_root.gotoandplay (1);
}

_totalframes

The _totalframes property is the total number of frames used to get the movie clip entity. You can also use to get the total number of frames for an animation. In the following example, you will see its usage.
I=_root.mc._totalframes;
if (_root.cuttentframes=i);
_root.stop ();
}
The program assigns the total number of frames in the movie clip entity to the variable I, and the animation stops playing when the main scene's animated playback pointer plays to the same number as the total number of frames in the movie clip. This property is also not an assignment property.

ifframesloaded

The ifframesloaded function is also used to get the number of frames that have been downloaded, unlike _framesloaded, which is used for a simple behavior that describes the number of frames that have been downloaded. And this function seems to be designed specifically for loading, which is located in the basic actions set, and the instruction name is the IF Frames is Loaded. The following example will constitute one of the simplest loading.
Ifframeloaded (_totalframes) {
gotoAndPlay (3);
}else{
gotoAndPlay (1);
}
Add this program to the second frame of the movie, which can be used for the preload technology of all animations. The meaning is to play the third frame when the number of frames loaded is the total number of frames, if not, play the first frame. This function is not recommended for use when more functions and properties are started after Flash5.

Getbytesloaded ()

The

getbytesloaded () Gets the number of downloaded bytes for the movie clip entity, or the total number of bytes of the animation if it is an external animation. Getbytesloaded is used for more precise loading design because it is not like the _framesloaded property is to get the total number of frames for a movie, but rather to get it in bytes. If the last frame of the animation will be a large image or voice character, then the percentage of _framesloaded will not be accurate, getbytesloaded effectively make up for this shortcoming. Example:
I=_root.getbytestotal ();
if (_root.getbytesloaded () >=1000000) {
    n=_root.getbytesloaded ();
    if (N<=I/4) {
        _root.stop ();
        trace ("Download 1M, less than One-fourth, animation is too large, download time will be very long, whether to continue?"
   }
}
This sentence means that when the animation is downloaded to 1MB, the comparison has already downloaded One-fourth of the animation, if it is, stop the animation of the playback, in the Debug window display "Download 1M, ..." and other strings, Determines whether to resume playback based on other behaviors in the animation. Another feature of this example is that the movie clips will not stop if there is a movie clip inserted in the Stop place. You can also display the number of text that has been downloaded by dynamic text, assuming that there is a dynamic text variable named text in the main scene of the animation, which example:
_root.text=_root.getbytesloaded ();
if (_root.getbytesloaded () >=_root.getbytestotal ()) {
    gotoandplay (3);
} else{
    gotoAndPlay (1);
} The
Dynamic text box dynamically displays the number of bytes that have been downloaded for audience service. Viewers will also understand the dynamic progress of the animation during the download process.

Getbytestotal ()

The Getbytestotal () function is used to get the total number of bytes of an animation or movie clip, and of course we can observe the total number of bytes of the animation by the size of the file, but it is necessary to display the file size dynamically for viewers who use browsers on the network. Also, if you want to see the volume of movie clips in an animation, you have to rely on the getbytestotal () function.
If (_root.getbytestotal () >=1000000) {
_root.stop ();
}
This program means that when the total byte of the animation exceeds 1M, the animation stops playing.

Gettimer ()

The Gettimer () function is used to get the number of times a movie clip or animation has played, and this function is not only applied to the production of loading, but will also come into contact with it in the course of future learning. In Flash5 control of animation playback time there will be Gettimer () function to show off the stage. However, the Gettimer () function gets the time in milliseconds as a unit of calculation, and generally in the process of making it divided by varying occupations to get seconds, so more in line with the display of time playback program. Suppose there is a dynamic text box variable with text in the animation. Cases:
Text=gettimer ()/1000;
Through the frame loop or other actions such as onclipevent (Enterframe), such as control will dynamically display the animation playback time process. Another example:
Text=gettimer ()/1000;
if (text>=10) {
gotoAndStop (3);
}else{
gotoAndPlay (1);
}
Suppose this program is in the second frame of the main scene of the animation. Then it will start playing for 10 seconds before it is officially played, otherwise it will only cycle between the first frame and the second frame.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.