[Flash basic theory Lesson 14] making loading[loading]

Source: Internet
Author: User

Back to "flash Basic Theory Class-Catalog"

Ideas:

1. Make a 100-frame reading animation, which can make a variety of loading effects;

2. Percentage read (percent) = bytes Read/total bytes *100;

3. Stop to the corresponding frame of the movie clip (Loading) based on the percentage of reads (percent).

Step 1:

Make a 100-frame loading animation, save as a movie clip, put on the stage, instance named loading

Step 2:

Add as code in the first frame

stop();
_root.onEnterFrame = function() {
var percent = Math.floor(getBytesLoaded()/getBytesTotal()*100);
//变量percent保存读取的百分比数
 loading.gotoAndStop(percent);
 //停止到影片剪辑 Loading 的相应帧上
 if (percent == 100) {
  _root.play();
  //percent=100时,说明读取完毕,整个动画开始播放
 }
};

Flash charge 1:getbytesloaded () and Getbytestotal ()

Getbytesloaded (): Gets the number of bytes read

Getbytestotal (): Gets the total number of bytes in the entire SWF file

Flash Charge 2: How to test whether the loading of the production is successful

1. Test loading must be used in the test film (Ctrl+enter);

2. We can import 2 larger pictures to occupy the byte number after frame 2nd;

3. After the test film (Ctrl+enter), select the view in the window-> Download Settings->dsl;

4. Select View-> Simulate Download (ctrl+enter) in the window.

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.