Guest User

Untitled

a guest
Jun 22nd, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. WHY DOES IT SAY IT CANT CALL setUserID??
  2.  
  3. AsyncErrorEvent: ReferenceError: Error #1069: Property setUserID not found on flash.net.NetConnection and there is no default value.
  4.  
  5. -------------------------------------------------------------------------------------
  6.  
  7. test.fla:
  8.  
  9. //import flash.net.NetConnection;
  10. import flash.net.SharedObject;
  11. import flash.events.Event;
  12. import flash.events.MouseEvent;
  13. import flash.events.NetStatusEvent;
  14. import flash.events.SecurityErrorEvent;
  15. import flash.events.SyncEvent;
  16. import flash.events.TimerEvent;
  17. import flash.utils.Timer;
  18. import flash.display.Sprite;
  19. import fl.data.DataProvider;
  20.  
  21. var nc:NetConnection=new NetConnection();
  22. var userSO:SharedObject;
  23. var chatSO:SharedObject;
  24. var myID:Number;
  25.  
  26. sendBtn.enabled=false;
  27. msgText.enabled=false;
  28.  
  29. myConn_btn.addEventListener(MouseEvent.CLICK, myConnect);
  30.  
  31. function myConnect(event:MouseEvent):void {
  32. switch (myConn_btn.label) {
  33. case "Connect" :
  34. if (userName.text!="") {
  35. if (userName.text!="Name") {
  36. debugWin.appendText("Connecting..."+"\n");
  37. userName.editable=false;
  38. myConn_btn.enabled=false;
  39. //sendBtn.addEventListener(MouseEvent.CLICK, onSendBtnClick);
  40. //deSelectBtn.addEventListener(MouseEvent.CLICK, onDeSelectBtnClick);
  41. //msgText.addEventListener("enter", onEnterPressed);
  42. //usersList.addEventListener(Event.CHANGE, onUserSelected);
  43. nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
  44. nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
  45. nc.connect("rtmpe://fms2.bongtvlive.com/test/v1", userName.text);
  46. nc.objectEncoding=ObjectEncoding.AMF3;
  47. } else {
  48. chatText.htmlText+="<b>Please enter a name</b><br>";
  49. }
  50. }
  51. break;
  52. case "Disconnect" :
  53. nc.close();
  54. chatText.htmlText+="<b>You have been disconnected</b><br>";
  55. myConn_btn.label="Connect";
  56. userName.editable=true;
  57. sendBtn.enabled=false;
  58. msgText.enabled=false;
  59. break;
  60. }
  61. }
  62.  
  63. function onNetStatus(event:NetStatusEvent):void {
  64. trace(event.info.code);
  65. switch (event.info.code) {
  66. case "NetConnection.Connect.Success" :
  67. debugWin.appendText("Connected!"+"\n");
  68.  
  69. myConn_btn.label="Disconnect";
  70. myConn_btn.enabled=true;
  71. break;
  72. case "NetConnection.Connect.Rejected" :
  73. debugWin.appendText("Connection rejected"+"\n");
  74. debugWin.appendText(event.info.application.msg+"\n");
  75. debugWin.appendText("Event: "+event.info.code+"\n");
  76. debugWin.appendText("Type: "+event.info.level+"\n");
  77. debugWin.appendText("Message:"+event.info.description+"\n");
  78. break;
  79. case "NetConnection.Connect.Failed" :
  80. debugWin.appendText("Connection failed."+"\n");
  81. break;
  82. case "NetConnection.Connect.Closed" :
  83. debugWin.appendText("Connection closed."+"\n");
  84. myConn_btn.label="Connect";
  85. break;
  86. }
  87. }
  88.  
  89. function asyncErrorHandler(event:AsyncErrorEvent) {
  90. trace("AsyncErrorEvent: "+event.error);
  91. }
  92.  
  93.  
  94. //AS2 method...
  95. //nc.setUserID = function(/*userId:Number,clientId:String*/){
  96. //setUserId();
  97. //}
  98.  
  99. //AS3 method...
  100. function setUserId():void {
  101. trace("setUserID> called from server..");
  102. //debugWin.appendText("userId/clientId received: "+userId+"/"+clientId+"\n");
  103. //myID=userId;
  104. //getUserListSO();
  105. //getChatSO();
  106. }
  107.  
  108.  
  109.  
  110. -------------------------------------------------------------------------------------
  111.  
  112. main.asc:
  113.  
  114. /*
  115. Between the time an instance is created and destroyed, a number of things can happen.
  116. To simplify how things work, they are divided into three sections: startup, midlife,
  117. and shutdown.
  118.  
  119. Each application object is a singleton object. Each instance gets it's own application
  120. object which is an instance of the Application class.
  121.  
  122. These are all the standard event handler method of the application object
  123. */
  124.  
  125. /***************************
  126. Startup
  127. ***************************/
  128.  
  129. application.onAppStart = function() {
  130. //A. onAppStart is where to Initialize counters, variables, id's, etc
  131. trace("onAppStart> "+application.name+" is starting at "+new Date());
  132. this.users = new Object;
  133. //B. You can set up a Server-side shared object to synchronize clients
  134. this.usersSO = SharedObject.get("userList_so", false);
  135. this.chatSO = SharedObject.get("chat_so", false);
  136. // this.test_so = SharedObject.get("test_so", true);
  137. //C. This is the proper way to set default variables. It allows for expansion
  138. // if (this.test_so.getProperty("t" == undefined)) {
  139. // }
  140. // if (this.test_so.getProperty("foo" == undefined)) {
  141. // }
  142. //Always assign unique ID's on the Server-Side because it's single threaded
  143. this.nextUserId = 0;
  144. };
  145.  
  146. application.onStatus = function(info) {
  147. trace("onStatus> info.level: "+info.level+", info.code: "+info.code);
  148. trace("onStatus> info.description: "+info.description);
  149. trace("onStatus> info.details: "+info.details);
  150. };
  151.  
  152. application.onConnect = function(clientObj, userName, password) {
  153. //A. Assign a uniqueID for any user who logs in
  154. clientObj.userId = this.nextUserId++;
  155. //B. Decide if a client needs a userName
  156. clientObj.userName = userName;
  157. //C. Decide if you want to give a client user read/write access
  158. //clientObj.writeAccess = "/public";
  159. //clientObj.readAccess = "/";
  160. //D. Inform the user that they have made a success connection
  161. this.acceptConnection(clientObj);
  162. this.users["user_"+clientObj.userId] = clientObj;
  163. this.usersSO.setProperty("user_"+clientObj.userId,clientObj);
  164. clientObj.call("setUserID",null/*,clientObj.userId,clientObj.id*/);
  165. //trace info
  166. trace("onConnect> clientObj.ip: "+clientObj.ip);
  167. trace("onConnect> clientObj.agent: "+clientObj.agent);
  168. trace("onConnect> clientObj.referrer: "+clientObj.referrer);
  169. trace("onConnect> clientObj.protocol: "+clientObj.protocol);
  170. trace("onConnect> clientObj.id/userId/userName/password: "+clientObj.id+"/"+clientObj.userId+"/"+userName+"/"+password);
  171. };
  172.  
  173. application.onDisconnect = function(clientObj) {
  174. //A. Clear any session variables that may pertain to a client user
  175. // (SharedObject variables)
  176. this.usersSO.setProperty("user_"+clientObj.userId,clientObj);
  177. delete this.users[clientObj.userId];
  178. //trace info
  179. trace("onDisconnect> clientObj.id/userId/userName: "+clientObj.id+"/"+clientObj.userId+"/"+clientObj.userName);
  180. trace("onDisconnect> disconnecting at: "+new Date());
  181. //this.nextUserId--;
  182. };
  183.  
  184. /***************************
  185. Shutdown
  186. ***************************/
  187.  
  188. application.onAppStop = function(info) {
  189. //A. For when the app stops
  190. trace("onAppStop> application.name: "+application.name);
  191. trace("onAppStop> stopping at "+new Date());
  192. trace("onAppStop> info.level: "+info.level);
  193. trace("onAppStop> info.code: "+info.code);
  194. trace("onAppStop> info.description: "+info.description);
  195. };
Add Comment
Please, Sign In to add comment