<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="initApp()">
<mx:Script>
<![CDATA[
private var timer:Timer;
public function initApp():void{
timer = new Timer(50);
timer.addEventListener(TimerEvent.TIMER,timer_Handler);
}
public function timer_Handler(evt:Event):void{
progressBar.setProgress(progressBar.value +1,100);
}
private function progressBar_complete(evt:Event):void{
timer.stop();
}
private function reset():void{
progressBar.setProgress(0,100);
progressBar.scaleX = 1;
progressBar.scaleY = 1;
progressBar.alpha = 1;
}
private function playProgressBar():void{
reset();
timer.start();
}
]]>
</mx:Script>
<mx:Parallel id="eff">
<mx:Fade alphaTo="0.0"/>
<mx:Zoom zoomHeightTo="0"/>
</mx:Parallel>
<mx:ProgressBar id="progressBar" complete="progressBar_complete(event);" mode="manual" completeEffect = "{eff}" labelPlacement="center" width = "400" height ="30"/>
<mx:Button label="开始加载" click="playProgressBar()"/>
</mx:Application>