0

I have this code below, what do I need to be able to be able to log with FireFox/FireBug:

package { import flash.display.Sprite; import flash.external.ExternalInterface; public class FlashRecorder extends Sprite { public function FlashRecorder() { var logger:Logger; logger = new Logger(); ExternalInterface.addCallback("debugLog", logger.debugLog); var recorder = new Recorder(logger); recorder.addExternalInterfaceCallbacks(); } } } 

Such that, when I do:

logger.log('startPlaying'); 

It will be logged in Firefox/firebug

5
  • or there is a tool that can log directly? I tried FlashFireBug but it wont log at all. Commented Oct 25, 2012 at 2:14
  • 1
    I'm not sure I understand the problem, is trace() not sufficient? you could also ExternalInterface.call("console.log('something to log')"); and could write method simply taking a string parameter and replacing 'something to log' Commented Oct 25, 2012 at 2:32
  • Ah I think you're just confused on the addCallback method help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… <-- this is for calling from javascript into the actionscript, to go the other way you just directly use ExternalInterface.call("javascriptHere"); Commented Oct 25, 2012 at 2:36
  • @shaunhusain I mean, when I load the compiled swf in my webapp I can't see any logs in firefox/firebug console. I need to log events from the swf to firefox Commented Oct 25, 2012 at 2:36
  • I believe at least in Chrome debug tools the console panel has to be open for the logs to be recorded, I'll try to check out Firefox's behavior... just verified this is true so the console needs to be open for the console.log messages to come through. Commented Oct 25, 2012 at 2:38

2 Answers 2

1

So far as debugging is concerned you've got quite a few options out there here's some options.

AS3

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package.html#trace()

http://www.as3commons.org/as3-commons-logging/

http://nochump.com/blog/archives/24

http://code.google.com/p/flash-tracer/

http://demonsterdebugger.com/

 private function logToBrowserConsole(somethingToLog:String):void { ExternalInterface.call("console.log", somethingToLog); } 

Flex 3+

http://livedocs.adobe.com/flex/3/html/help.html?content=logging_09.html

http://code.google.com/p/fxspy/

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry had the function wrong RTFM me! :) tested the above function it works in firefox, I've also used all those other tools and found them to be way more useful than tracing when things get hairy.
1

To log with FireBug, you just using: console.log, detail in http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.