1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| /*
*************************************
* ProgressBar componente Flash CS3 *
* http://www.FlepStudio.org *
* © Author: Filippo Lughi *
* version 1.0 *
*************************************
*/
package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import fl.containers.UILoader;
import fl.controls.Label;
import flash.text.TextFieldAutoSize;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
public class Main extends MovieClip
{
private var UI_loader:UILoader
private var etichetta:Label;
private var url:String;
public function Main()
{
init();
}
private function init():void
{
replay_btn.visible=false;
bar_pb.visible=true;
url='http://www.itch.fr/images/flash/video.swf';
UI_loader=new UILoader();
UI_loader.autoLoad=false;
UI_loader.source=url;
UI_loader.move(stage.stageWidth/2,stage.stageHeight/2);
UI_loader.scaleContent=false;
UI_loader.load();
bar_pb.source=UI_loader;
bar_pb.move(stage.stageWidth/2-bar_pb.width/2,stage.stageHeight/2);
bar_pb.addEventListener(ProgressEvent.PROGRESS,progresso);
bar_pb.addEventListener(Event.COMPLETE,completato);
etichetta=new Label();
etichetta.text='Chargement';
etichetta.autoSize=TextFieldAutoSize.LEFT;
etichetta.move(bar_pb.x,bar_pb.y+bar_pb.height);
addChild(etichetta);
}
private function progresso(e:ProgressEvent):void
{
etichetta.text=int(e.currentTarget.percentComplete)+'%';
}
private function completato(e:Event):void
{
bar_pb.removeEventListener(ProgressEvent.PROGRESS,progresso);
bar_pb.removeEventListener(Event.COMPLETE,completato);
bar_pb.visible=false;
removeChild(etichetta);
addChild(UI_loader);
UI_loader.move(0,0);
swapChildren(UI_loader,replay_btn);
replay_btn.visible=true;
initButtonListener();
}
private function initButtonListener():void
{
replay_btn.addEventListener(MouseEvent.MOUSE_DOWN,reload);
}
private function reload(m:MouseEvent):void
{
UI_loader.unload();
removeChild(UI_loader);
init();
}
}
} |
Partager