Skip to content

Instantly share code, notes, and snippets.

@JesterXL
Created February 27, 2012 17:06
Show Gist options
  • Save JesterXL/1925484 to your computer and use it in GitHub Desktop.
Save JesterXL/1925484 to your computer and use it in GitHub Desktop.
Simple way to show trace statements in Flash and in the browser. Put in root. Go: console.log("Hello World!");
package
{
import flash.external.ExternalInterface;
public class console
{
public function console()
{
}
private static function printToBrowserConsole(method:String, message:String):void
{
try
{
ExternalInterface.call(method, message);
}
catch(error:Error)
{
trace("console::printToBrowserConsole, error: " + error);
}
}
public static function log(o:*):void
{
printToBrowserConsole("console.log", String(o));
}
public static function debug(o:*):void
{
printToBrowserConsole("console.debug", String(o));
}
public static function info(o:*):void
{
printToBrowserConsole("console.info", String(o));
}
public static function warn(o:*):void
{
printToBrowserConsole("console.warn", String(o));
}
public static function error(o:*):void
{
printToBrowserConsole("console.error", String(o));
}
// [jwarden 4.26.2012] NOTE: fatal is routed to error.
public static function fatal(o:*):void
{
printToBrowserConsole("console.error", String(o));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment