Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Created January 4, 2013 07:41
Show Gist options
  • Save IQAndreas/4450713 to your computer and use it in GitHub Desktop.
Save IQAndreas/4450713 to your computer and use it in GitHub Desktop.
Log data to both JavaScript and ActionScript (useful for switching between testing in the IDE and testing on the server)
package
{
import flash.external.ExternalInterface;
/** Will send the text to trace and JavaScript console (if available)
* Only to be used for debugging. Not to be used for final release! */
public function log(... args):String
{
// Log a blank line if nothing is passed
var str:String = (args.length > 0) ? args.join(" ") : "-----------------------------------";
// JavaScript log (use something like FireBug to see the output)
if (ExternalInterface.available)
{ ExternalInterface.call("console.log", str); }
// ActionScript log
trace(str);
return str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment