// 创建剪辑来承载您的内容 this.createEmptyMovieClip ("progressBar_mc", 0); progressBar_mc.createEmptyMovieClip ("bar_mc", 1); progressBar_mc.createEmptyMovieClip ("stroke_mc", 2); progressBar_mc.createTextField ("pre_txt", 3, 0, -2, 100, 20); // 使用绘画方法创建一个进度条100*10 // 进度条的边框,黑色 with (progressBar_mc.stroke_mc) { lineStyle (0, 0x000000); moveTo (0, 0); lineTo (100, 0); lineTo (100, 10); lineTo (0, 10); lineTo (0, 0); } // 进度条的填充色,红色 with (progressBar_mc.bar_mc) { beginFill (0xFF0000, 100); moveTo (0, 0); lineTo (100, 0); lineTo (100, 10); lineTo (0, 10); lineTo (0, 0); endFill (); _xscale = 0; } // 百分比的字体样式 var myformat:TextFormat = new TextFormat (); myformat.font = "Verdana"; myformat.size = 10; myformat.color = 0xFFFFFF; // 百分比的显示 with (progressBar_mc.pre_txt) { text = "0%"; type = "dynamic"; setTextFormat (myformat); } // 进度条的开始位置 progressBar_mc._x = 200; progressBar_mc._y = 550; //加载进度 var mclListener:Object = new Object (); mclListener.onLoadStart = function (target_mc:MovieClip) { progressBar_mc.bar_mc._xscale = 0; }; mclListener.onLoadProgress = function (target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) { progressBar_mc.bar_mc._xscale = Math.round (bytesLoaded / bytesTotal * 100); progressBar_mc.pre_txt.text = Math.round (bytesLoaded / bytesTotal * 100) + "%"; progressBar_mc.pre_txt.setTextFormat (myformat); }; mclListener.onLoadComplete = function (target_mc:MovieClip) { // progressBar_mc.removeMovieClip (); }; mclListener.onLoadInit = function (target_mc:MovieClip) { // target_mc._height = 500; // target_mc._width = 700; }; // 创建一个剪辑来承载图像。 this.createEmptyMovieClip ("image_mc", 100); var image_mcl:MovieClipLoader = new MovieClipLoader (); image_mcl.addListener (mclListener); /* 将图像加载到剪辑中。 You can change the following URL to a SWF or another image file. */ image_mcl.loadClip ("http://www.helpexamples.com/flash/images/gallery1/images/pic1.jpg", image_mc);