Loading| Standard
SWF Movies in the network can be downloaded while playing, because of the current network transmission constraints, for large-capacity films, this real-time playback is not ideal. To avoid embarrassing waiting for the audience, flash production staff often design a load (loading) of the screen, such as all the bytes of the movie downloaded to the local and then play, so as to ensure the quality of the movie playback. This paper introduces a standard method of loading production.
Steps:
1. Open the Flash MX 2004, select the Rectangle tool, and draw the next one in the home scene. Only the border has a rectangle, in this case the rectangle is 350*16 pixels.
2. Again in the home scene with a rectangular tool to draw a rectangle with only fill without a border, and press the F8 key to convert it to a movie clip (note: Its registration point must be selected at the left of the rectangle), its instance named bar. In this case, the rectangle size is 345*11 pixels.
3. The above two rectangles are arranged in the home scene so that the bounding rectangle is nested filled with rectangles.
4. Next to both rectangles, drag a dynamic text box with a type tool named Bar_per.
At this point, the preparation is ready, that is, the creation of two rectangular boxes and a dynamic text box, the following preparation of code.
5. In the home scene, a new layer, select the layer 1th frame, press F9 to open the Action Script editing window, enter the following code:
Following the boom, Macromedia has also developed a Flash animation player for use on mobile phones: Flash Lite 1.1. Initially this player can only be used in I-mode handheld devices, and later Sony Ericsson, Nokia brand Some mobile phones can also use the player. In the market this year has been able to see bundled flash Lite 1.1 mobile phones, especially Samsung mobile phones and Macromedia reached a cooperative agreement, full support for Flash Lite 1.1.
This.onload=function () {
Mybytestotal=_root.getbytestotal ();
}
This.onload ();
This.onenterframe=function () {
Mybytesloaded=_root.getbytesloaded ();
bar_xscale=mybytesloaded/mybytestotal*100;
Percent=math.round (Bar_xscale);
This.bar._xscale=bar_xscale;
this.bar_per=percent+ "%";
if (mybytesloaded==mybytestotal) {
Delete This.onenterframe;
_root.nextframe ();
}else{
This.stop ();
}
}
6. Make your Flash video from the main scene timeline from frame 2nd.
Annotations:
①
This.onload=function () {
Mybytestotal=_root.getbytestotal ();
}
This code refers to the total number of bytes of all elements present in the main timeline that are read and assigned to variable mybytestotal when the movie clip (in this case, the home view of the two rectangles and a dynamic text box) loads.
Ii
This.onload ();
Flash event handler function movieclip.onload=function () {...} A bit odd, where the code is set, if not followed by This.onload (), the code does not execute, so add this sentence so that the code can be executed.
③
Mybytesloaded=_root.getbytesloaded ()///reads the number of bytes loaded by all elements that exist in the main timeline and assigns them to the variable mybytesloaded.
④
bar_xscale=mybytesloaded/mybytestotal*100;//converts the mybytestotal to 100, the converted value obtained by mybytesloaded is assigned to the variable Bar_xscale, To assign the _xscale of bar in the main scene (the maximum value of the _xscale can only be 100), where the proportional calculation of elementary mathematics is used.
⑤
Percent=math.round (Bar_xscale);//Assign the value of the variable Bar_xscale to the variable percent so that the percentage shown is not fractional.
Expand:
1. "Download Speed" code design
① a dynamic text box with the appropriate width in the home scene with the text tool and set its variable name to rate.
② appends the following code before the This.onenterframe=function () {} code body if statement at the home scene code layer 1th frame:
T=gettimer ();
rate= "Download speed:" + math.round (mybytesloaded/t * 100)/100 +
"K/S";
2. Code design for "time spent and remaining time"
① a dynamic text box with the appropriate width in the home scene with the text tool and set its variable name to Mytimes.
② appends the following code before the This.onenterframe=function () {} code body if statement at the home scene code layer 1th frame:
Timeloaded=math.round (t/1000);
Timeremain=math.round (timeloaded* (mybytestotal-mybytesloaded)/mybytesloaded);
Timeremain=math.round (TIMEREMAIN/60) + ":" +math.round (TIMEREMAIN%60);
Timeloaded=math.round (TIMELOADED/60) + ":" +math.round (TIMELOADED%60);
Mytimes= "has used time" +timeloaded+ "" + "remaining Time" +timeremain;
Note: If the "Download Speed" code is not designed, then the above code should append code T=gettimer ();
The whole code for the 1th frame of the rear scene code layer is expanded as follows:
This.onload=function () {
Mybytestotal=_root.getbytestotal ();
}
This.onload ();
This.onenterframe=function () {
Mybytesloaded=_root.getbytesloaded ();
bar_xscale=mybytesloaded/mybytestotal*100;
Percent=math.round (Bar_xscale);
This.bar._xscale=bar_xscale;
this.bar_per=percent+ "%";
T=gettimer ();
rate= "Download speed:" + math.round (mybytesloaded/t * 100)/100 +
"K/S";
Timeloaded=math.round (t/1000);
Timeremain=math.round (timeloaded* (mybytestotal-mybytesloaded)/mybytesloaded);
Timeremain=math.round (TIMEREMAIN/60) + ":" +math.round (TIMEREMAIN%60);
Timeloaded=math.round (TIMELOADED/60) + ":" +math.round (TIMELOADED%60);
Mytimes= "has used time" +timeloaded+ "" + "remaining Time" +timeremain;
if (mybytesloaded==mybytestotal) {
Delete This.onenterframe;
_root.nextframe ();
}else{
This.stop ();
}
}