CreateRoom.as 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import flash.external.*;
  2. ExternalInterface.addCallback("c2f_QueryPlatform_CreateRoom_Callback", this, c2f_QueryPlatform_CreateRoom_Callback);
  3. ExternalInterface.call("f2c_QueryPlatform","c2f_QueryPlatform_CreateRoom_Callback");
  4. function c2f_QueryPlatform_CreateRoom_Callback(platform:String):Void
  5. {
  6. if (platform=="RakNet")
  7. {
  8. }
  9. else
  10. {
  11. lanGameCheckbox.visible=false;
  12. roomMembersCanInviteCheckbox.visible=false;
  13. }
  14. }
  15. cancelButton.addEventListener("click", this, "Cancel");
  16. function Cancel()
  17. {
  18. gotoAndStop("Lobby");
  19. }
  20. okButton.addEventListener("click", this, "CreateRoom");
  21. function CreateRoom()
  22. {
  23. ExternalInterface.call("f2c_CreateRoom",
  24. [roomNameTextInput.text,
  25. mapNameTextInput.text,
  26. Number(publicSlotsTextInput.text),
  27. Number(reservedSlotsTextInput.text),
  28. hiddenFromSearchesCheckbox.selected,
  29. roomMembersCanInviteCheckbox.selected,
  30. lanGameCheckbox.selected
  31. ]);
  32. }
  33. // Duplicated
  34. ExternalInterface.addCallback("c2f_CreateRoom", this, c2f_CreateRoom);
  35. function c2f_CreateRoom(resultCode:String, isLanGame:Boolean):Void
  36. {
  37. if (resultCode=="REC_SUCCESS")
  38. {
  39. if (isLanGame)
  40. {
  41. gotoAndStop("InGame");
  42. }
  43. else
  44. {
  45. gotoAndStop("InRoom");
  46. }
  47. }
  48. else
  49. {
  50. trace("c2f_CreateRoom failure. Result= " + resultCode);
  51. /*
  52. REC_CREATE_ROOM_UNKNOWN_TITLE,
  53. REC_CREATE_ROOM_CURRENTLY_IN_QUICK_JOIN,
  54. REC_CREATE_ROOM_CURRENTLY_IN_A_ROOM,
  55. */
  56. }
  57. }
粤ICP备19079148号