A simple and easy-to-use progress bar

Source: Internet
Author: User
Add the following code to-root the first frame is OK.
var Myloading:movieclip;
var Loadinfo:movieclip;
var _linebgcolor = "0x666666";
var _linecolor = "0X0000FF";
var _linelen:number = 200;
var _lineh:number = 3;
var _txtcolor;
var _txtalign:string = "center";
var Tb:number;
var txtformat:textformat = new TextFormat ("Arial", NULL, 0x000000, true); myloading = _root.createemptymovieclip ("myloading", 10); Progress bar
Loadinfo = Myloading.createemptymovieclip ("line", 10);
Loadinfo.linestyle (1, _linecolor, 20);
Loadinfo.moveto (0, 0);
Loadinfo.lineto (_linelen, 0);
Loadinfo.lineto (_linelen, _lineh);
Loadinfo.lineto (0, _lineh);
Loadinfo.lineto (0, 0); Progress display text
Loadinfo.createtextfield ("TXT", 0, 0, _linelen, 22);
LoadInfo.txt.autoSize = _txtalign; Set the position of the progress bar (centered at the home view)
loadinfo._x = (Stage.width-_linelen)/2;
loadinfo._y = STAGE.HEIGHT/2; Get the movie size and stop, then Onenterframe
TB = _root.getbytestotal ();
_root.stop ();
Myloading.onenterframe = function () {
var lb:number = _root.getbytesloaded ();
var percent:number = Math.Round (lb/tb*100);
LoadInfo.txt.text = percent+ "%";
LoadInfo.txt.setTextFormat (Txtformat);

Loadinfo.linestyle (_lineh, _linebgcolor, 10);
Loadinfo.moveto (0, _LINEH/2);
Loadinfo.lineto (percent*_linelen/100, _LINEH/2);

if (percent = = 100) {
_root.play ();
Delete This.onenterframe;
Loadinfo.clear ();
LoadInfo.txt.text = "";
}
}
Mailto:hjs0724@163.com


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.