Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-11-2003, 13:04   #1 (permalink)
Neuer User
 
Registriert seit: Jun 2003
Ort: Wien
Beiträge: 166
Question debug probleme

hi!

Nachdem ich gerade meine ganzen AS2-Scripts wieder auf AS1 zurückkonvertier, habe ich mir jetzt mal wieder ein Problem eingehandelt, bei dem ich nicht schlau werde.

Folgende "Klasse" (habe ich aus dem o'Reilly ActionScript Buch):
ActionScript:
  1. /*
  2. *  SocketController Class extends XMLSocket
  3. *  ActionScript 1
  4. *  version:  0.1b          // Flash 6 version
  5. *  descr.:   provides services for communicating with a socket server
  6. *
  7. *  Methods
  8. *    doConnect()             - connect to server
  9. *    setServer()             - set server host:port
  10. *    killConnect()           - disconnect from server
  11. *    send()                  - send XML to server
  12. *
  13. *  Event Handlers
  14. *    onConnectFailure()
  15. *    onConnectSuccess()
  16. *    onServerKillConnect()
  17. *    onClientKillConnect()
  18. */
  19.  
  20. //  set superclass to XMLSocket
  21. SocketController.prototype  = new XMLSocket();
  22.  
  23. //  class constructor
  24. function SocketController (host, port) {
  25.   this.host = null;
  26.   this.port = 0;
  27.  
  28.   if (arguments.length > 1) {
  29.     this.setServer(host, port);
  30.   }
  31. }
  32.  
  33. //  try to establish connection to server
  34. SocketController.prototype.doConnect  = function() {
  35.   if (this.host == null || this.port < 1024) {
  36.     trace ("Connection attempt aborted: invalid host or port!");
  37.     this.onConnectFailure();
  38.     return false;
  39.   } else {
  40.     var connectSuccess  = this.connect(this.host, this.port);
  41.   }
  42.   if (connectSuccess) {
  43.     trace ("initial connection succeeded. Awaiting server response ....");
  44.   } else {
  45.     trace ("initial connection failed");
  46.     this.onConnectFailure();
  47.   }
  48. };
  49.  
  50. //  set host and port of server
  51. SocketController.prototype.setServer = function(host, port) {
  52.   if (typeof host != "string"
  53.       || typeof port != "number"
  54.       || (typeof port =="number" && port < 1024)) {
  55.      this.host  = null;
  56.      this.port  = false;
  57.      return false;
  58.   }
  59.    
  60.   this.host  = host;
  61.   this.port  = port;
  62. };
  63.  
  64. //  callback to respond to the completion of a connection attempt
  65. SocketController.prototype.onConnect  = function (success) {
  66.   if (success) {
  67.     trace ("Connection to: " + this.host + ":" + this.port  + " established.");
  68.     this.onConnectSuccess();
  69.   } else {
  70.     trace ("Connection to: " + this.host + ":" + this.port + " could not be established.");
  71.     this.onConnectFailure();
  72.   }
  73. };
  74.  
  75. //  callback invoked when server kills connection
  76. SocketController.prototype.onClose  = function() {
  77.   trace ("server has terminated the connection");
  78.   this.onServerKillConnect();
  79. };
  80.  
  81. //  close the connection
  82. SocketController.prototype.killConnect  = function() {
  83.   trace ("Closing connection");
  84.   this.close();
  85.   this.onClientKillConnect();
  86. };
  87.  
  88. //  send Data to socket
  89. SocketController.prototype.socketSend = function(message) {
  90.   this.send(message);
  91. };

und hier meine Aktionen, die ich aus der ersten Fame aufrufe:

ActionScript:
  1. #include "SocketController.as"
  2.  
  3. var _TEST   = false;
  4.  
  5. var _LiveScore;
  6. var sheight = 600;
  7. var swidth  = 800;
  8. var _deep   = 1;
  9. var _sst    = 35;      // declares the top of the framed stage
  10. var _ssb    = 600;    // declares the bottom of the framed stage
  11. var _ssh    = 0;        // declares the heigth of the frames stage
  12.  
  13. // system.useCodepage = true;
  14. // makeStyle();
  15. main();
  16. fscommand("fullscreen", "true");
  17.  
  18. function main() {
  19.     if (TEST) {
  20.         getXML  = new XML();
  21.         getXML.load("test.xml");
  22.         trace (myXML);
  23.     } else {
  24.         getXML  = new SocketController();
  25.         getXML.setServer("10.1.1.26", 7000);
  26.         getXML.doConnect();
  27.         getXML.onConnectSuccess = function () {
  28.             trace ("Connection established");
  29.         }
  30.        
  31.         getXML.socketSend("INIT");
  32.        
  33.         var i:Number = 0;
  34.         getXML.onXML = function (scr) {
  35. //      trace ("--------------------------- received XML -----------------------------");
  36.             if (i==0) {
  37.                 if (ConnectOK(scr)) {
  38.                     trace ("Server sent: " + scr);
  39.                 } else {
  40.                     trace ("Server did not send OK");
  41.                 }
  42.             } else {
  43.                 trace ("Server sent XML");
  44.                 trace (scr);
  45.                 useXML(scr);
  46.             }
  47.             i++;
  48.         }
  49.     }
  50. }

also mein Problem bezieht sich auf das Debuggen des Movies. Wenn ich einen Breakpoint am Anfang des Scripts setze und mich dann durch den Source hantel, komme ich bis zu dieser Zeile im Klassenkonstruktor:
ActionScript:
  1. var connectSuccess  = this.connect(this.host, this.port);
Wenn ich die Zeile ausführen lasse, führt Flash das ganze Projekt bis zum Schluss aus und ich kann nicht genau sagen, was er macht... Das ist natürlich ziemlich nervend!

Was mache ich falsch?
mfg
Juro
JuRo ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 04:02 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele