/
Menu.as
74 lines (58 loc) · 2.02 KB
/
Menu.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
package
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.MouseEvent;
import com.bit101.components.Component;
import com.bit101.utils.MinimalConfigurator;
import com.bit101.components.Label;
import com.bit101.components.PushButton;
import com.bit101.components.List;
import flash.net.*;
public class Menu extends Sprite
{
public var myLabel:Label;
public var pushButton:PushButton;
public var gameList:List;
public var netConnection:NetConnection;
public var responder:Responder;
public function Menu(myStage:Stage):void
{
Component.initStage(myStage);
netConnection = new NetConnection();
netConnection.connect("http://192.168.137.156:8080");
var xml:XML = <comps>
<Panel x="10" y="10" width="200" height="500"/>
<VBox x="20" y="10">
<Label id="myLabel" text="Current Games"/>
<List id="gameList" width="170"/>
<PushButton id="pushButton" label="Select Game"/>
</VBox>
</comps>;
var config:MinimalConfigurator = new MinimalConfigurator(this);
config.parseXML(xml);
responder = new Responder(onComplete, onFail);
netConnection.call("mastermind.listGames", responder);
pushButton.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(event:MouseEvent):void
{
trace("I'm clicked!");
}
public function onComplete(results):void
{
trace("success!");
for each (var thisGame in results)
{
trace(thisGame['_key'])
trace(thisGame);
gameList.addItem(thisGame['_key']);
}
}
public function onFail(results):void
{
trace("failed!");
trace(results);
}
}
}