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
| function launchSWF(vBox, vFile):void{
var swfLoader:Loader = new Loader();
//vBox.addChild(swfLoader);
var swfURL:URLRequest = new URLRequest(vFile);
swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
swfLoader.load(swfURL);
var player:swfPlayerBt = new swfPlayerBt();
function loadProdComplete(e:Event):void {
trace("swf file loaded");
vBox.removeChild(preLoader);
vBox.addChild(swfLoader);
currentSWF = MovieClip(swfLoader.content);
currentSWF.gotoAndPlay(1);
player.x =200;
player.y =350;
//attach the swfPlayer buttons
vBox.addChild(player);
//add EventListeners for swfPlayer buttons
player.btForward.addEventListener(MouseEvent.CLICK, button_forward);
player.btRewind.addEventListener(MouseEvent.CLICK, button_rewind);
player.btPause.addEventListener(MouseEvent.CLICK, button_pause);
player.btPlay.addEventListener(MouseEvent.CLICK, button_play);
currentSWF.addEventListener(Event.ENTER_FRAME , checkLastFrame);
function checkLastFrame(e:Event):void {
if (currentSWF.currentFrame == currentSWF.totalFrames) {
currentSWF.stop();
// trace("DONE");
}
}
function button_forward(e:Event):void{
currentSWF.nextFrame();
}
function button_rewind(e:Event):void{
currentSWF.prevFrame();
}
function button_pause(e:Event):void{
currentSWF.stop();
}
function button_play(e:Event):void{
currentSWF.play();
}
}
var preLoader:loader = new loader();
preLoader.x = 400;
preLoader.y = 450;
vBox.addChild(preLoader);
function onProgressHandler(event:ProgressEvent){
var dataAmountLoaded:Number=event.bytesLoaded/event.bytesTotal*100;
preLoader.bar.scaleX = dataAmountLoaded/100;
preLoader.lpc.text= int(dataAmountLoaded)+"%";
trace(preLoader.bar.scaleX );
}
}
var container:MovieClip = new MovieClip();
var swfFile:String = 'http://og-zone.com/swf/Dragon%20and%20Weed-S2%20E022.swf';
var currentSWF:MovieClip = new MovieClip();
launchSWF(container, swfFile);
//put it on stgae
addChild(container); |
Partager