-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSwitcher.as
84 lines (65 loc) · 1.54 KB
/
Switcher.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
package {
//import fl.video.VideoAlign;
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.media.Sound;
public class Switcher extends MovieClip {
protected static var sound_tab:Sound_Tab;
protected var current_index:int;
public var name_list:Vector.<String>;
public function Switcher(itemname:String="武器\nweapon") {
// constructor code
tf_item.text = itemname;
current_index = 0;
name_list = new Vector.<String>();
sound_tab = new Sound_Tab();
}
public function init():void
{
//call this after this switcher is ready
update();
lb.addEventListener(MouseEvent.CLICK, move_left);
rb.addEventListener(MouseEvent.CLICK, move_right);
}
protected function update():void
{
dispatchEvent(new Event(Event.CHANGE));
tf_current.text = name_list[current_index];
}
protected function move_left(e:MouseEvent):void
{
sound_tab.play();
if (current_index > 0)
{
current_index--;
}
else
{
current_index = name_list.length - 1;
}
update();
//temp for animation
dispatchEvent(new Event(Bar.click_event, true));
}
protected function move_right(e:MouseEvent):void
{
sound_tab.play();
if (current_index < name_list.length - 1)
{
current_index++;
}
else
{
current_index = 0;
}
update();
//temp for animation
dispatchEvent(new Event(Bar.click_event, true));
}
public function get_current():int
{
return current_index;
}
}
}