views:

1940

answers:

6

I'm developing an applications which I've got running on a server on my linux desktop. Due to the shortcomings of Flash on Linux (read: too hard) I'm developing the (small) flash portion of the app in Windows, which means there's a lot of frustrating back and forth. Now I'm trying to capture the output of the flash portion using flash tracer and that is proving very difficult also. Is there any other way I could monitor the output of trace on linux? Thanks...

A: 

If you only need the trace output at runtime, you can use Firebug in Firefox and then use Flash.external.ExternalInterface to call the console.log() Javascript method provided by Firebug.

I've used that strategy multiple times to a large degree of success.

Justin Niessner
Haha I'm trying to trace errors I'm getting with ExternalInterface Here's the post: http://stackoverflow.com/questions/818089/using-externalinterface-in-flash
danwoods
But thanks for the info about console.log() I'll definitely use that once I get externalInterface working
danwoods
A: 

Thunderbolt is a great logging framework with built-in firebug support.

moritzstefaner
Any idea about how to include the classes? (I think that's how it's supposed to work...)
danwoods
Just put them in the class path and import them. Here are some more tips and tricks: http://www.websector.de/blog/2008/06/15/10-tips-and-tricks-using-thunderbolt-as3/
moritzstefaner
+1  A: 

A different and mind-bogglingly simple workaround that I've used for years is to simply create an output module directly within the swf. All this means is a keyboard shortcut that attaches a MovieClip with a textfield. All my traces go to this textfield instead of (or in addition to) the output window. Over the years I've refined it of course, making the window draggable, resizable, etc. But I've never needed any other approach for simple logging, and it's 100% reliable and reusable across all platforms.

[EDIT - response to comment] There's no alert quite like javascript's alert() function. But using an internal textfield is just this simple:

ACTIONSCRIPT 1 VERSION


(See notes at bottom)

/* import ExternalInterface package */
import flash.external.*;

/* Create a movieclip for the alert. Set an arbitrary (but very high) number for the depth
 * since we want the alert in front of everything else.
 */
var alert = this.createEmptyMovieClip("alert", 32000);
/* Create the alert textfield */
var output_txt = alert.createTextField("output_txt", 1, 0, 0, 300, 200);
output_txt.background = true;
output_txt.backgroundColor = 0xEFEFEF;
output_txt.selectable = false;
/* Set up drag behaviour */
alert.onPress = function()
{
    this.startDrag();
}
alert.onMouseUp = function()
{
    stopDrag();
}

/* I was using a button to text EI. You don't need to. */
testEI_btn.onPress = function()
{
    output_txt.text = (ExternalInterface.available);
}

Notes: This works fine for AS1, and will translate well into AS2 (best to use strong data-typing if doing so, but not strictly required). It should work in Flash Players 8-10. ExternalInterface was added in Flash 8, so it won't work in previous player versions.

ACTIONSCRIPT 3 VERSION


var output_txt:TextField = new TextField();
addChild(output_txt);
output_txt.text = (String(ExternalInterface.available));

If you want to beef it out a bit:

var alert:Sprite = new Sprite();
var output_txt:TextField = new TextField();
output_txt.background = true;
output_txt.backgroundColor = 0xEFEFEF;
output_txt.selectable = false;
output_txt.width = 300;
output_txt.height = 300;
alert.addChild(output_txt);
addChild(alert);

alert.addEventListener(MouseEvent.MOUSE_DOWN, drag);
alert.addEventListener(MouseEvent.MOUSE_UP, stopdrag);

output_txt.text = (String(ExternalInterface.available));

function drag(e:MouseEvent):void
{
    var alert:Sprite = e.currentTarget as Sprite;
    alert.startDrag();
}

function stopdrag(e:MouseEvent):void
{
    var alert:Sprite = e.currentTarget as Sprite;
    alert.stopDrag();
}

[/EDIT]

Wikiup
I've thought about that too. How could I make a popup window that gives me the value of ExternalInterface.available? There's got to be a function in flash similar to alert() in javascript...
danwoods
Sweet. I cannot wait to try this. I keep feeling like I'm getting closer and closer.. Thanks for all of that...
danwoods
First version does nothing, second 'beefed-up' version gives compiler errors. I've highlighted what I believe are the appropriate lines here -> http://pastebin.com/f3b3791c2 if anyone wants to look over them (please)
danwoods
Compiler errors (there were 5) from the beefed-up version included 2 or 3 referencing the 'sprite' command. I must have some problem with that...
danwoods
Sorry danwoods, I didn't include the import statements at the top, which is almost certainly the source of your woes here. You need to make sure you are importing flash.display.Sprite (and perhaps flash.text.TextField and flash.events.MouseEvent as well).
Wikiup
Thanks. Using the basic version you listed: var output_txt:TextField = new TextField(); addChild(output_txt); output_txt.text = (String(ExternalInterface.available));and importing flash.text.*, I publish with no errors but in my output box I get 'undefined'. Is this the output I'm looking for?
danwoods
I kind of thought this would open up a new window with this information at run time
danwoods
Can't import the Sprites or MouseEvent apparently. I tried using display.Sprite and events.MouseEvent and got several errors, then switched to display.* and events.* and still got errors. Current code is listed here http://pastebin.com/f32ec18d and the errors are as follows:
danwoods
The class or interface 'Sprite' could not be loaded.(var alert:Sprite = new Sprite();) -- The class or interface 'MouseEvent' could not be loaded. (function drag(e:MouseEvent):void)-- The class or interface 'Sprite' could not be loaded. (var alert:Sprite = e.currentTarget as Sprite;)-- The class or interface 'MouseEvent' could not be loaded. (function stopdrag(e:MouseEvent):void)-- The class or interface 'Sprite' could not be loaded. (var alert:Sprite = e.currentTarget as Sprite;)--Thanks for all your time - Dan
danwoods
So it acts like it's not importing anything. Any idea what could cause that?
danwoods
Sorry, Dan, I'd have responded earlier, but I'm new to SO and didn't correctly see the signs that you'd been commenting back. I also need to apologise that I jumped to the conclusion that you were working in AS3, but it looks from your code that you're working in AS1 or AS2 (probably AS1). That's not a problem...we just need to re-write my example in an AS1-friendly way (will work for AS2 as well). I'll edit my original answer in a few minutes!
Wikiup
AS1/2 version now posted.
Wikiup
Thanks so much for all the help Wikiup! I'll let you know the results as soon as I try this.
danwoods
Well, using the AS1 version broke the player (ie: it loads visually, but doesn't do anything). The player is written in AS2. I don't even know what data-types flash uses, so I guess I'll start there. All I really want to do is make one outgoing function call to javascript. I never knew I'd have to learn so much flash...
danwoods
I tried moving the "output_txt.text = (ExternalInterface.available);" outside of the button and commenting out the button and I tried commenting out the drag function but the player loses all functionality when I add in the code you posted. Do I need to change anything in the .fla file? What could be causing this? Thanks again for all your patiences. I was frustrated earlier, but now I really want to know what's causing the problem!
danwoods
I set DEFAULT_WELCOME_MSG to equal ExternalInterface.available and now when the player loads it says 'undefined'. Does that make any sense?
danwoods
Current code is posted here: http://pastebin.com/f5fe9a985
danwoods
actionScript 2 + calling html is here: http://pastebin.com/f4724111d
danwoods
I suggest you keep it simple. Don't try to make this work within the context of your player right off. Just create a new, blank document, place a textfield onstage, name it output_txt and then run the single line of code: output_txt.text = ExternalInterface.available; Try that and make sure the EI works...then build up from there. If it does, you can work out why it's not intereacting well with your player. If it doesn't, figuring out why should be your first concern.
Wikiup
+2  A: 

Hope this helps too (for the sake of google search i came from):

In order to do trace, you need the debugger version of Flash Player from http://www.adobe.com/support/flashplayer/downloads.html (look for "debugger" version specifically - they are hard to spot on first look)

Then an mm.cfg file in your home containing

ErrorReportingEnable=1 TraceOutputFileEnable=1 MaxWarnings=50

And then you are good to go - restart the browser. When traces start to fill in, you will find the log file in

~/.macromedia/Flash_Player/Logs/flashlog.txt

Something like

tail ~/.macromedia/Flash_Player/Logs/flashlog.txt -f

Should suffice to follow the trace.

tm_lv
That's what I'm trying to do. (see here: http://stackoverflow.com/questions/827843/installing-flash-9-debugger-in-linux ) If you can figure that out, please let me know, and thanks for the reply...
danwoods
Errrm, use plain `trace("stuff)` instead of externalinterface thing and you will start seeing texts floing into the log file.
tm_lv
A: 

To implement FlashTracer, head to the following address and be sure you have the latest file. http://www.sephiroth.it/firefox/flashtracer/ . Install it and restart the browser.

Head over to adobe and get the latest flash debugger. Download and install the firefox version as FlashTracer is a firefox addition.

Now that firefox has the latest flash debugger and flash tracer we need to locate mm.cfg

-Location on PC C:\Documents and Settings\username

Inside of mm.cfg should be:

ErrorReportingEnable=1 TraceOutputFileEnable=1 MaxWarnings=100 //Change to your own liking.

Once that is saved, open firefox, head to the flash tracer window by heading to tools > flash tracer. In the panel that pops up there is two icons in the bottom right corner, click the wrench and make sure the path is set to where your log file is being saved. Also check to see that flash tracer is turned on, there is a play/pause button at the bottom.

I currently use this implementation and hope that it works for you. Flash Tracer is a little old, but works with the newest versions of FireFox. I am using it with FireFox 3.0.10

Brian Hodge
http://blog.hodgedev.com

Brian Hodge
A: 

I use the flex compiler on linux to build actionscript files, [embed(source="file")] for all my assets including images and fonts, I find actionscript development on linux very developer friendly.

Then again, I'm most interested in that flash has become Unix Friendly as aposed to the other way around :)

Fire Crow