1 | /**
|
---|
2 | * ...
|
---|
3 | * @author Default
|
---|
4 | * @version 0.1
|
---|
5 | */
|
---|
6 |
|
---|
7 | package {
|
---|
8 | import flash.display.Sprite;
|
---|
9 | import flash.text.TextField;
|
---|
10 | import flash.text.TextFormat;
|
---|
11 | import flash.events.Event;
|
---|
12 | import flash.filters.DropShadowFilter;
|
---|
13 |
|
---|
14 | public class Loading extends Sprite {
|
---|
15 | private var tf:TextField;
|
---|
16 |
|
---|
17 | public function Loading( text:String ) {
|
---|
18 |
|
---|
19 | this.tf = new TextField();
|
---|
20 | this.tf.text = text;
|
---|
21 |
|
---|
22 | var fmt:TextFormat = new TextFormat();
|
---|
23 | fmt.color = 0x000000;
|
---|
24 | fmt.font = "Verdana";
|
---|
25 | fmt.size = 12;
|
---|
26 | fmt.align = "center";
|
---|
27 |
|
---|
28 | this.tf.setTextFormat(fmt);
|
---|
29 | this.tf.autoSize = "left";
|
---|
30 | this.tf.x = 5;
|
---|
31 | this.tf.y = 5;
|
---|
32 |
|
---|
33 | //
|
---|
34 | // HACK! For some reason the Stage.height is not
|
---|
35 | // correct the very first time this object is created
|
---|
36 | // so we wait untill the first frame before placing
|
---|
37 | // the movie clip at the center of the Stage.
|
---|
38 | //
|
---|
39 |
|
---|
40 | this.addEventListener( Event.ENTER_FRAME, this.onEnter );
|
---|
41 |
|
---|
42 | this.addChild( this.tf );
|
---|
43 |
|
---|
44 | this.graphics.lineStyle( 2, 0x808080, 1 );
|
---|
45 | this.graphics.beginFill( 0xf0f0f0 );
|
---|
46 | this.graphics.drawRoundRect(0, 0, this.tf.width + 10, this.tf.height + 10, 5, 5);
|
---|
47 |
|
---|
48 | var spin:Sprite = new Sprite();
|
---|
49 | spin.x = this.tf.width + 40;
|
---|
50 | spin.y = (this.tf.height + 10) / 2;
|
---|
51 |
|
---|
52 | var radius:Number = 15;
|
---|
53 | var dots:Number = 6;
|
---|
54 | var colours:Array = [0xF0F0F0,0xD0D0D0,0xB0B0B0,0x909090,0x707070,0x505050,0x303030];
|
---|
55 |
|
---|
56 | for( var i:Number=0; i<dots; i++ )
|
---|
57 | {
|
---|
58 | var deg:Number = (360/dots)*i;
|
---|
59 | var radians:Number = deg * (Math.PI/180);
|
---|
60 | var x:Number = radius * Math.cos(radians);
|
---|
61 | var y:Number = radius * Math.sin(radians);
|
---|
62 |
|
---|
63 | spin.graphics.lineStyle(0, 0, 0);
|
---|
64 | spin.graphics.beginFill( colours[i], 1 );
|
---|
65 | spin.graphics.drawCircle( x, y, 4 );
|
---|
66 | }
|
---|
67 |
|
---|
68 | this.addChild( spin );
|
---|
69 |
|
---|
70 | var dropShadow:DropShadowFilter = new DropShadowFilter();
|
---|
71 | dropShadow.blurX = 4;
|
---|
72 | dropShadow.blurY = 4;
|
---|
73 | dropShadow.distance = 4;
|
---|
74 | dropShadow.angle = 45;
|
---|
75 | dropShadow.quality = 2;
|
---|
76 | dropShadow.alpha = 0.5;
|
---|
77 | // apply shadow filter
|
---|
78 | this.filters = [dropShadow];
|
---|
79 |
|
---|
80 | /*
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 | spin.onEnterFrame = function ()
|
---|
85 | {
|
---|
86 | this._rotation += 5;
|
---|
87 | }
|
---|
88 |
|
---|
89 | */
|
---|
90 | }
|
---|
91 |
|
---|
92 | private function onEnter(event:Event):void {
|
---|
93 |
|
---|
94 | if( this.stage ) {
|
---|
95 | this.x = (this.stage.stageWidth/2)-((this.tf.width+10)/2);
|
---|
96 | this.y = (this.stage.stageHeight/2)-((this.tf.height+10)/2);
|
---|
97 | // this.removeEventListener( Event.ENTER_FRAME, this.onEnter );
|
---|
98 | // tr.ace('ppp');
|
---|
99 | }
|
---|
100 | this.getChildAt(1).rotation += 5;
|
---|
101 | }
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | }
|
---|