Many different ways, of course, depending on the details of your app. (And globals aren't by definition "evil" -- in fact in Flash, they can be quite useful.) One approach would be to define a publicly accessible static method, which you could call from anywhere in your code, and might be defined as a separate class like so:
package
{
public class MyCustomLogger
{
public function MyCustomLogger()
{
//
}
public static function log(text:String):void
{
trace(text);
}
}
}
Defined this way, you might call your log function using ClassName.staticFunctionName notation from anywhere in your app:
[some code...]
MyCustomLogger.log("My log text.")
[some more code...]
This kind of approach is pretty common. From there, it can get more complicated, depending on your needs; your post indicates you want to write the string to a TextField object, in which case the static log function would require either a reference to that TextField object when it's called, or its own static access path to the TextField instance as defined elsewhere in your application. In that case, I might suggest defining a global instance variable into whose constructor you might pass a reference to the TextField target (and writing to it with your log function), or various other approaches -- again, depending on your specific needs. But for purposes of illustration, using a publicly accessible static method is one fairly standard approach you might consider.