This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CircleLoaderExample.as
56 lines (42 loc) · 2.02 KB
/
CircleLoaderExample.as
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
//AS3///////////////////////////////////////////////////////////////////////////
// seanhellwig@gmail.com
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.text.TextFormat;
import flash.net.URLRequest;
import com.seanhellwig.preloaders.CirclePreloader;
[SWF(width="650", height="650", backgroundColor="#FFFFFF", frameRate="30")]
public class CircleLoaderExample extends Sprite {
private var _loader:Loader = new Loader();
private var _loaderTF:TextFormat;
private var _circleLoader:CirclePreloader;
private static const RADIUS:int = 300;
//test image found on google images, using it because it is large in filesize.
private static const TEST_IMAGE:String = "http://mms.space.swri.edu/MMSposter-large.jpg";
public function CircleLoaderExample() {
_loaderTF = new TextFormat();
_loaderTF.size = 125;
_circleLoader = new CirclePreloader(0x000000, 25, 1.0, RADIUS, true, _loaderTF);
this.addChild(_circleLoader);
_loader.contentLoaderInfo.addEventListener(Event.OPEN, onOpen);
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
//extra url query string added for no caching purposes
_loader.load(new URLRequest(TEST_IMAGE+"?"+new Date().toString()));
}
private function onOpen(e:Event):void{
_circleLoader.reset();
trace("init");
}
private function onProgress(e:ProgressEvent):void {
_circleLoader.update(e.bytesLoaded, e.bytesTotal);
}
private function onComplete(e:Event):void{
trace("load completed");
}
}
}