ENTER_FRAME事件做进度条
package { /** * @author zoe * */ import flash.display.Sprite; import flash.events.Event; public class Main extends Sprite { private var rect:Sprite; private var bar:Sprite; public function Main() { init(); } private function init():void { rect = new Sprite(); rect.graphics.lineStyle(1,0xff6699); // rect.graphics.beginFill(0x00ff00); rect.graphics.drawRect(0,0,200,30); rect.graphics.endFill(); rect.x = 50; rect.y = 300; addChild(rect); bar = new Sprite(); bar.graphics.beginFill(0x00ff00); bar.graphics.drawRect(0,0,1,29); bar.graphics.endFill(); addChild(bar); bar.x = 51; bar.y = 301; addEventListener(Event.ENTER_FRAME,efHandler); } protected function efHandler(event:Event):void { // TODO Auto-generated method stub bar.width+= 2; if(bar.width >=rect.width-2) { bar.width = rect.width-2; removeEventListener(Event.ENTER_FRAME,efHandler); } } } }