QQ给图片加了防盗,有空再换个图片吧。 点击下载 源码 提取码 18a84ab2
Main
1package {
2 import flash.display.Loader;
3 import flash.display.Sprite;
4 import flash.events.Event;
5 import flash.events.IOErrorEvent;
6 import flash.events.ProgressEvent;
7 import flash.net.URLRequest;
8
9 [SWF(width="713", height="456", frameRate="24",background="#xffffff")]
10 public class Main extends Sprite
11 {
12 private var bgLoader:Loader;
13 private var loadingPanel:LoadingPanel;
14
15 public function Main()
16 {
17 this.bgLoader = new Loader();
18 this.loadingPanel = new LoadingPanel();
19 this.bgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
20 this.bgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, bgCompleteHandler);
21 this.bgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
22 this.bgLoader.load(new URLRequest("http://cnc.imgcache.qq.com/qqhome_v2/parker/bgitem/1000002.jpg"));
23 this.addChild(this.bgLoader);
24 this.addChild(this.loadingPanel);
25 this.loadingPanel.show();
26 }
27
28 private function ioErrorHandler(ioErrorEvent:IOErrorEvent):void
29 {
30
31 }
32
33 private function bgCompleteHandler(event:Event):void
34 {
35 this.loadingPanel.hide();
36 }
37
38 private function progressHandler(event:ProgressEvent):void
39 {
40 var bytesLoaded:Number;
41 var bytesTotal:Number;
42 var currentPercent:uint;
43 bytesLoaded = event.bytesLoaded;
44 bytesTotal = event.bytesTotal;
45 if (bytesLoaded > 20 && bytesLoaded <= bytesTotal)
46 {
47 currentPercent = Math.round(bytesLoaded * 100 / bytesTotal);
48 trace(currentPercent);
49 this.loadingPanel.pro(currentPercent);
50 }
51 return;
52 }
53 }
54}
1package {
2 import flash.display.Loader;
3 import flash.display.Sprite;
4 import flash.events.Event;
5 import flash.events.IOErrorEvent;
6 import flash.events.ProgressEvent;
7 import flash.net.URLRequest;
8
9 [SWF(width="713", height="456", frameRate="24",background="#xffffff")]
10 public class Main extends Sprite
11 {
12 private var bgLoader:Loader;
13 private var loadingPanel:LoadingPanel;
14
15 public function Main()
16 {
17 this.bgLoader = new Loader();
18 this.loadingPanel = new LoadingPanel();
19 this.bgLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
20 this.bgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, bgCompleteHandler);
21 this.bgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
22 this.bgLoader.load(new URLRequest("http://cnc.imgcache.qq.com/qqhome_v2/parker/bgitem/1000002.jpg"));
23 this.addChild(this.bgLoader);
24 this.addChild(this.loadingPanel);
25 this.loadingPanel.show();
26 }
27
28 private function ioErrorHandler(ioErrorEvent:IOErrorEvent):void
29 {
30
31 }
32
33 private function bgCompleteHandler(event:Event):void
34 {
35 this.loadingPanel.hide();
36 }
37
38 private function progressHandler(event:ProgressEvent):void
39 {
40 var bytesLoaded:Number;
41 var bytesTotal:Number;
42 var currentPercent:uint;
43 bytesLoaded = event.bytesLoaded;
44 bytesTotal = event.bytesTotal;
45 if (bytesLoaded > 20 && bytesLoaded <= bytesTotal)
46 {
47 currentPercent = Math.round(bytesLoaded * 100 / bytesTotal);
48 trace(currentPercent);
49 this.loadingPanel.pro(currentPercent);
50 }
51 return;
52 }
53 }
54}
LoadingPanel
1package
2{
3 import flash.display.*;
4 import mx.effects.*;
5 import mx.effects.easing.*;
6
7 public class LoadingPanel extends MovieClip
8 {
9 private var loadingBar:LoadingBar;
10 private var myTween:Tween;
11
12 public function LoadingPanel()
13 {
14 this.loadingBar = new LoadingBar();
15 addChild(this.loadingBar);
16 this.x = 260;
17 this.y = 200;
18 this.mouseEnabled = false;
19 this.visible = false;
20 }
21
22 public function hide() : void
23 {
24 this.visible = false;
25 return;
26 }
27
28 public function pro(currentPercent:uint) : void
29 {
30 this.loadingBar.pro.text = "已载入:" + currentPercent + "%";
31 return;
32 }
33
34 public function show() : void
35 {
36 this.visible = true;
37 this.loadingBar.pro.text = "请稍候";
38 this.myTween = new Tween(this.loadingBar,0,1,1.5,-1,this.onUpdateFunction,this.onEndFunction);
39 return;
40 }
41
42 private function onUpdateFunction(value:Object):void
43 {
44 this.loadingBar.alpha = value as Number;
45 }
46
47 private function onEndFunction(value:Object):void
48 {
49 this.loadingBar.alpha = value as Number;
50 }
51 }
52}
1package
2{
3 import flash.display.*;
4 import mx.effects.*;
5 import mx.effects.easing.*;
6
7 public class LoadingPanel extends MovieClip
8 {
9 private var loadingBar:LoadingBar;
10 private var myTween:Tween;
11
12 public function LoadingPanel()
13 {
14 this.loadingBar = new LoadingBar();
15 addChild(this.loadingBar);
16 this.x = 260;
17 this.y = 200;
18 this.mouseEnabled = false;
19 this.visible = false;
20 }
21
22 public function hide() : void
23 {
24 this.visible = false;
25 return;
26 }
27
28 public function pro(currentPercent:uint) : void
29 {
30 this.loadingBar.pro.text = "已载入:" + currentPercent + "%";
31 return;
32 }
33
34 public function show() : void
35 {
36 this.visible = true;
37 this.loadingBar.pro.text = "请稍候";
38 this.myTween = new Tween(this.loadingBar,0,1,1.5,-1,this.onUpdateFunction,this.onEndFunction);
39 return;
40 }
41
42 private function onUpdateFunction(value:Object):void
43 {
44 this.loadingBar.alpha = value as Number;
45 }
46
47 private function onEndFunction(value:Object):void
48 {
49 this.loadingBar.alpha = value as Number;
50 }
51 }
52}