-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPointMeter2.as
76 lines (59 loc) · 1.24 KB
/
PointMeter2.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
package {
import flash.display.MovieClip;
import flash.events.Event;
//information board 里的柱状器
public class PointMeter2 extends MovieClip {
private var value:int;
private var target:int;
private var max:int
private static const speed:Number = 0.5;
public function PointMeter2() {
// constructor code
value = 0;
addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
}
public function onAddToStage(event:Event):void
{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
removeEventListener(Event.ADDED_TO_STAGE, onAddToStage);
}
public function Update(current:int,cmax:int):void
{
target = current;
max = cmax;
//txtValue.text = String(current);
}
public function onEnterFrame(event:Event):void
{
var d:Number = target-value;
if (Math.abs(d) <= 1)
{
value = target;
}
else
{
value = int(Number(value+d * speed));
}
/*
if (target > value)
{
value += 5;
if (value > target)
{
value = target;
}
}
else if (target < value)
{
value-= 5;
if (value < target)
{
value = target;
}
}
*/
txtValue.text = String(value);
meter.scaleX = Number(value / max);
}
}
}