Created
February 27, 2012 17:06
-
-
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!");
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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