1 | class Control extends MovieClip |
---|
2 | { |
---|
3 | public var play_mc:MovieClip; |
---|
4 | public var pause_mc:MovieClip; |
---|
5 | public var background_mc:MovieClip; |
---|
6 | |
---|
7 | public var initialState:String; |
---|
8 | public var realWidth:Number; |
---|
9 | |
---|
10 | public var state:String; |
---|
11 | |
---|
12 | public var addListener:Function; |
---|
13 | public var removeListener:Function; |
---|
14 | private var broadcastMessage:Function; |
---|
15 | |
---|
16 | /** |
---|
17 | * Constructor |
---|
18 | */ |
---|
19 | function Control() |
---|
20 | { |
---|
21 | AsBroadcaster.initialize(this); |
---|
22 | |
---|
23 | if(this.state == "play") this.pause_mc._visible = false; |
---|
24 | else this.play_mc._visible = false; |
---|
25 | |
---|
26 | this.realWidth = this.background_mc._width; |
---|
27 | |
---|
28 | background_mc.hover_mc._visible = play_mc.hover_mc._visible = pause_mc.hover_mc._visible = false; |
---|
29 | } |
---|
30 | |
---|
31 | function onRollOver() |
---|
32 | { |
---|
33 | _switch(true); |
---|
34 | } |
---|
35 | |
---|
36 | function onRollOut() |
---|
37 | { |
---|
38 | _switch(false); |
---|
39 | } |
---|
40 | |
---|
41 | function onReleaseOutside() |
---|
42 | { |
---|
43 | _switch(false); |
---|
44 | } |
---|
45 | |
---|
46 | function onRelease() |
---|
47 | { |
---|
48 | this.toggle(true); |
---|
49 | } |
---|
50 | |
---|
51 | private function _switch(toggle:Boolean):Void |
---|
52 | { |
---|
53 | if(this.state == "play") this.play_mc.hover_mc._visible = toggle; |
---|
54 | if(this.state == "pause") this.pause_mc.hover_mc._visible = toggle; |
---|
55 | this.background_mc.hover_mc._visible = toggle; |
---|
56 | } |
---|
57 | |
---|
58 | public function toggle(broadcast:Boolean):Void |
---|
59 | { |
---|
60 | if(broadcast == undefined) broadcast = false; |
---|
61 | if(this.state == "play") |
---|
62 | { |
---|
63 | if(broadcast) broadcastMessage("onPlay"); |
---|
64 | this.play_mc._visible = false; |
---|
65 | this.play_mc.hover_mc._visible = false; |
---|
66 | this.pause_mc._visible = true; |
---|
67 | this.state = "pause"; |
---|
68 | } else |
---|
69 | { |
---|
70 | if(broadcast) broadcastMessage("onPause"); |
---|
71 | this.pause_mc._visible = false; |
---|
72 | this.pause_mc.hover_mc._visible = false; |
---|
73 | this.play_mc._visible = true; |
---|
74 | this.state = "play"; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | public function flip():Void |
---|
79 | { |
---|
80 | this.background_mc._rotation = 180; |
---|
81 | this.background_mc._y = this.background_mc._height; |
---|
82 | this.background_mc._x = this.background_mc._width; |
---|
83 | //this.play_mc._rotation = 180; |
---|
84 | //this.play_mc._y += this.play_mc._height; |
---|
85 | this.play_mc._x = 14; |
---|
86 | this.pause_mc._x = 13; |
---|
87 | } |
---|
88 | } |
---|