-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointMeter3.as
96 lines (71 loc) · 1.74 KB
/
PointMeter3.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
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
95
96
package {
import flash.display.MovieClip;
import flash.events.Event;
//information board 里的柱状器
public class PointMeter3 extends MovieClip {
private var value:int;
private var target:int;
private var max:int
private static const speed:Number = 0.5;
public function PointMeter3(rank:int,color:uint=1) {
// constructor code
value = 0;
txtName.text = "胜场";
txtRank.text = String(rank);
meter.gotoAndStop(color);
addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
}
public function onAddToStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, onAddToStage);
}
public function SetText(armor_name:String,author_name:String):void
{
txtArmorInfo.text = armor_name + " " + author_name;
}
public function Update(current:int,cmax:int):void
{
target = current;
max = cmax;
//txtValue.text = String(current);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event):void
{
/*
//相同时间填充
var d:Number = target-value;
if (Math.abs(d) <= 1)
{
value = target;
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
else
{
value = int(Number(value+d * speed));
}
*/
//速度相同
if (target > value)
{
value += 1;
if (value > target)
{
value = target;
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
else if (target < value)
{
value-= 1;
if (value < target)
{
value = target;
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
txtValue.text = String(value)+"/"+String(max);
meter.scaleX = Number(value / max);
}
}
}