[haXe] trace not working for me

Nicolas Cannasse ncannasse at motion-twin.com
Thu Jan 4 11:06:39 CET 2007


>>Ok, sorry for the mistake, I only realized afterwords when I took a 
>>look at my implemntation, but you got it working ...
>>   
>>
> 
> dont worry :)
> I updated it to show firebug specific messages.... Im starting to love haxe

Now in the standard library (haxe.Firebug) !
Works for both Javascript, Flash 6-7-8 and Flash 9

class Firebug {

	public static function redirectTraces() {
		haxe.Log.trace = trace;
	}

	public static function trace(v : Dynamic, ?inf : haxe.PosInfos ) {
		var type = if( inf.customParams != null ) inf.customParams[0] else null;
		if( type != "warn" && type != "info" && type != "debug" && type !=
"error" )
			type = "log";
		#if flash
			var out = "javascript:console."+ type +"('" + inf.fileName + ":" +
inf.lineNumber + " : " +
Std.string(v).split("\\").join("\\\\").split("'").join('\\"') + "');";
			#if flash9
			var l = new flash.net.URLLoader();
			l.addEventListener( "ioError", function(e){} );
			l.load(new flash.net.URLRequest(out));
			#else true
			flash.Lib.getURL(out);
			#end // flash9
		#else js
			untyped console[type](inf.fileName+":"+inf.lineNumber+" :
"+Std.string(v));
		#else error
		#end
	}

}
Nicolas



More information about the Haxe mailing list