ConnectToServer_RakNet.as 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import flash.external.*;
  2. connectToServerButton.addEventListener("click", this, "connectToServer");
  3. ExternalInterface.addCallback("c2f_connectToServer_callback", this, c2f_connectToServer_callback);
  4. function connectToServer()
  5. {
  6. ExternalInterface.call("f2c_ConnectToServer", ipAddressTextInput.text, portTextInput.text, "c2f_connectToServer_callback");
  7. }
  8. function c2f_connectToServer_callback(callSucceeded : Boolean)
  9. {
  10. if (callSucceeded==false)
  11. gotoAndStop("Main");
  12. }
  13. ExternalInterface.addCallback("c2f_NotifyConnectionAttemptToServerSuccess", this, c2f_NotifyConnectionAttemptToServerSuccess);
  14. function c2f_NotifyConnectionAttemptToServerSuccess():Void
  15. {
  16. gotoAndStop("Accounts_RakNet");
  17. }
  18. ExternalInterface.addCallback("c2f_NotifyConnectionAttemptToServerFailure", this, c2f_NotifyConnectionAttemptToServerFailure);
  19. function c2f_NotifyConnectionAttemptToServerFailure(resultCode:String, systemAddress:String):Void
  20. {
  21. // Result codes are:
  22. // CONNECTION_ATTEMPT_FAILED
  23. // ALREADY_CONNECTED
  24. // NO_FREE_INCOMING_CONNECTIONS
  25. // RSA_PUBLIC_KEY_MISMATCH
  26. // CONNECTION_BANNED
  27. // INVALID_PASSWORD
  28. trace(resultCode);
  29. gotoAndStop("Main");
  30. }
  31. stop();
粤ICP备19079148号