title: AS3 calling a global function with out 'new' or having a static method
body: <p>I'm creating a utility function for debugging/logs, which I access by importing the class and calling</p>
  
  <p><code>new Log(params);</code></p>
  
  <p>Alternatively I change the function to a static, and rename it to <code>It</code>,</p>
  
  <p>then I can call it by <code>Log.It(params)</code></p>
  
  <p>I'm wondering if it possible to set it up so I can simply call <code>Log(params)</code> similar to the <code>trace</code> command?</p>
  
  <p>function:</p>
  
  <pre><code>package 
  {
  public class Log 
  {
      /** Gets the name of the function which is calling */
      public function Log(prefix:String = "", suffix:String = "", params:* = null):void 
      {
          var error:Error = new Error();
          var stackTrace:String = error.getStackTrace();     // entire stack trace
          var startIndex:int = stackTrace.indexOf("at ", stackTrace.indexOf("at ") + 1); //start of second line
          var endIndex:int = stackTrace.indexOf("()", startIndex);   // end of function name
  
          var lastLine:String = stackTrace.substring(startIndex + 3, endIndex);
          var functionSeperatorIndex:int = lastLine.indexOf('/');
          var ClassSeperatorIndex:int = lastLine.indexOf(':');
  
          var objectName:String = lastLine.substring(ClassSeperatorIndex+2, functionSeperatorIndex);
          var functionName:String = lastLine.substring(functionSeperatorIndex + 1, lastLine.length);
  
          //TODO: Loop through params
  
          trace(prefix +" " + "[" + objectName + "]" + " &gt; " + functionName + " " + suffix);
  
          //TODO: Log to Array
          //TODO: Dispatch Event
      }
  }
  }
  </code></pre>