initial commit
[CPE_learningsite] / CPEFlex / EngagementPod / src / EngagementPod.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
3                                 xmlns:components="com.adobe.sync.components.*"
4                                 xmlns:local="*"
5                                 minWidth="200" minHeight="200" backgroundColor="#CCCCCC" layout="absolute">
6         
7         <mx:Script>
8                 <![CDATA[
9                         import com.adobe.sync.events.SyncSwfEvent;
10                         
11                         import mx.controls.Alert;
12                         import mx.core.UIComponent;
13                         import mx.events.FlexEvent;
14                         import mx.rpc.events.FaultEvent;
15                         
16                         import models.CustomSyncMessage;
17                         import models.Settings;
18                                                 
19                         [bindable] public var settings:Settings;
20                         private var comp:UIComponent;
21                         
22                         public function syncConnector_caughtUpHandler():void {
23                                 
24                                 settings = new Settings(syncConnector);
25 //                              settings.syncConnector.addEventListener(SyncSwfEvent.ROLE_CHANGED,syncConnector_roleChangedHandler);
26                                 settings.syncConnector.allowParticipantPublish(CustomSyncMessage.USER_ADD_MSG, true);
27                                 settings.syncConnector.allowParticipantPublish(CustomSyncMessage.PARTICIPANT_INVALID_ID, true);
28                                 settings.loadComplete = true;
29                                 toggleInterface();
30                         }
31                         
32 //                      protected function syncConnector_roleChangedHandler(event:SyncSwfEvent):void {
33 //                              toggleInterface();
34 //                      }
35                         
36                         protected function toggleInterface():void {
37                                 mainContainer.removeAllChildren();
38                                 comp = null;
39                                 clearGC();
40                                 if(settings.syncConnector.role == "owner" ){
41                                         comp = new Host();
42                                 }
43                                 else if(settings.syncConnector.role == "presenter"){
44                                         comp = new Presenter();
45                                 }
46                                 else{
47                                         comp = new Participant();
48                                 }
49                                 mainContainer.addChild(comp);
50                         }
51                         
52                         public function clearInterface():void {
53                                 mainContainer.removeAllChildren();
54                                 comp = null;
55                                 clearGC();
56                         }
57                         
58                         private function clearGC():void {
59                                 try {
60                                         new LocalConnection().connect('foo');
61                                         new LocalConnection().connect('foo');
62                                 } catch (e:*) {}
63                                 System.gc();
64                                 System.gc();
65                         }
66                         
67                         public var logText:String = "";
68                         public function LOG(msg:String):void{
69                                 txtLog.text += msg + "\n";
70                                 logText += msg + "_cr_";
71                         }
72                         
73                         public function cpeservice_faultHandler(event:FaultEvent):void{
74                                 var message:String = "Unable to connect to cpeonlinewebcast server.";
75                                 
76                                 if(settings.syncConnector.role == "viewer"){
77                                         message += "\n  Please click 'Show Log' and copy the contents of the log to send to the meeting host.";
78                                         hLogButtons.visible = true;
79                                         hLogButtons.includeInLayout = true;
80                                         btnShowLog.visible = true;
81                                         btnShowLog.includeInLayout = true;
82                                 }
83                                 Alert.show(message);
84                         }
85                         
86                         public function connectservice_faultHandler(event:FaultEvent):void{
87                                 Alert.show("Unable to connect to Adobe connect server.");
88                         }
89                         
90                         protected function btnShowLog_clickHandler(event:MouseEvent):void
91                         {
92                                 txtLog.x = 10;
93                                 txtLog.y = 10;
94                                 txtLog.percentHeight = 80;
95                                 txtLog.visible = true;
96                                 txtLog.includeInLayout = true;
97                                 btnShowLog.visible = false;
98                                 btnShowLog.includeInLayout = false;
99                                 btnHideLog.visible = true;
100                                 btnHideLog.includeInLayout = true;
101                         }
102                         
103                         protected function btnHideLog_clickHandler(event:MouseEvent):void
104                         {
105                                 txtLog.visible = false;
106                                 txtLog.includeInLayout = false;
107                                 btnHideLog.visible = false;
108                                 btnHideLog.includeInLayout = false;
109                                 hLogButtons.visible = false;
110                                 hLogButtons.includeInLayout = false;
111                         }
112                         
113                 ]]>
114         </mx:Script>
115
116         <mx:VBox id="mainContainer" width="100%" height="100%"/>
117         <mx:TextArea id="txtLog" left="10" bottom="10" width="100%" height="100" text="" visible="false" includeInLayout="false"/>
118         <mx:HBox width="100%" id="hLogButtons" visible="false" includeInLayout="false">
119                 <mx:Button id="btnShowLog" label="Show Log" visible="false" includeInLayout="false" click="btnShowLog_clickHandler(event)" />
120                 <mx:Button id="btnHideLog" label="Hide Log" visible="false" includeInLayout="false" click="btnHideLog_clickHandler(event)" />
121         </mx:HBox>
122         <components:SyncConnector id="syncConnector" caughtUp="syncConnector_caughtUpHandler()"/>
123
124 </mx:Application>