Thema: traceMessages
Einzelnen Beitrag anzeigen
Alt 03-04-2003, 19:01   #8 (Permalink)
tumetom
Coalado
 
Registriert seit: Jun 2001
Ort: Lagcity.de
Beiträge: 683
debug

heir passen vieleicht folgene sachen ganz gut rein:


Mich hat es beim debuggen hin und wieder gestört, dass ich nicht wusste welcher Klasse eine instanz angehört.


typeof ist da nur bedingt hilfreich.


damit gehts aber eigentlich ganze gut...:



ActionScript:
  1. Function.prototype.subscribe = function(name) {
  2.     if (Function.reference == null) {
  3.         Function.reference = [];
  4.     }
  5.     var ref = Function.reference;
  6.     this.unSubscribe();
  7.     this.counter++;
  8.     ref.push([this.prototype, name, this.counter]);
  9.     return true;
  10. };
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. Function.prototype.unSubscribe = function() {
  20.     var ref = Function.reference;
  21.     var max = ref.length;
  22.     for (var i = 0; i<max; i++) {
  23.         if (ref[i][0] == this.prototype) {
  24.             ref.splice(i, 1);
  25.             return true;
  26.         }
  27.     }
  28.     return false;
  29. };
  30.  
  31.  
  32.  
  33. //Anfügen einiger  internen Klassen
  34. Array.subscribe("Array");
  35. Date.subscribe("Date");
  36. Function.subscribe("Function");
  37. Object.subscribe("Object");
  38. String.subscribe("String");
  39. Number.subscribe("Number");
  40. Selection.subscribe("Selection");
  41. Color.subscribe("Color");
  42. MovieClip.subscribe("MovieClip");
  43. Sound.subscribe("Sound");
  44. TextField.subscribe("TextField");
  45.  
  46.  
  47. Object.prototype.getID = function() {
  48.     var ref = Function.reference;
  49.     var max = ref.length;
  50.     for (var i = 0; i<max; i++) {
  51.         if (ref[i][0] == this.__proto__) {
  52.             return ref[i][1];
  53.         }
  54.     }
  55.     return false;
  56. };
  57.  
  58.  
  59. Object.prototype.toString = function(arg) {
  60.     var ID = this.getID();
  61.     var str = ASnative(101, 4);
  62.     if (ID != false && arg != true) {
  63.         return str()+"  -  "+ID;
  64.     } else {
  65.         return str();
  66.     }
  67. };
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. myArray=[]
  78.  
  79. trace(myArray) // ausgabe:  [Object-Object]   - Array
  80.  
  81.  
  82.  
  83. _global.klasse=function(){
  84.    
  85.     //...}
  86.    
  87. klasse.subscribe("Klasse")
  88.    
  89.    
  90.  
  91.    
  92.     myClass=new Klasse()
  93.    
  94.     trace(myClass)  // ausgabe:  [Object-Object]   - Klasse
  95.     trace(myClass.getID())   // ausgabe  Klasse
  96.  


MFG tumetom
tumetom ist offline   Mit Zitat antworten