Flash: Troubleshooting flashlog.txt not being generated? Another tip..check ADL.exe
Ran in to an interesting, where the trace utility SOS Max stopped working. For a bit I thought it was something about setting up Flash 10 debug version. It wasn't at least entirely.
I first followed the instructions here which are just the basic settings. and made sure that the debug version was installed by going to the version check
mm.cfg was set to a place that SOS wasn't looking at C:\flashlog.txt, which may have been the Flash 10 install. So I reset it to what SOS was expecting e.g.
C:\Documents and Settings\Troy Gardner\Application Data\Macromedia\Flash Player\Logs
But that still didn't work. So I tried deleting flashlog.txt and couldn't do it, as it was in use by AIR, adl.exe ... in fact two instances of them, likely spawned by Flash CS3 publishing for AIR. Unlocking them, allowed the Flash CS3 and various other flash debug players to write to the log file again.
ALSO in the same folder policyfiles.txt was a whopping 200MB! This is due to apppend in the mm.cfg being set to true, so beware that you clean up periodically if you do have it on (e.g. if your fishing for intermittent bugs)
Flash: FDT Workflow, debugging with FDT with SOS or the built in Debugger
Powerflasher's FDT is the best actionscript editor on the planet (yes IMO better than FlexBuilder), SOS is it's one of the two primary options.
SOS is a Java based Trace Console that is much faster than the one built into Flash CS3, it offers regexp for filtering, searching, line coloring, collapsing. It's fast, and it's XMLSocket based so can be used pretty much anywhere. It has some neat features that allow you to create menus that issue commands, so your app can 'talk' to the SOS, creating menu items to callback to run different tests. Here's a long post covering how to use it.
A new one in FDT Enterprise is the built in Debugger. Which works similarly to the one built into Eclipse for coding Java (also similar to the one in the Flash IDE) allowing breakpoints, introspecting variables, stepping through. This useful feature as far as I know hasn't been in any non-Adobe tool, up to this point, as it has only recently become possible. Here's a great short tutorial if you haven't used it before.
Flash: SOS Max, the best Flash trace() output debugger on the planet
PowerFlasher has released a new verison of the best trace output debugger on the planet (IMO). Called SOS Max. Though the new version was released just a month ago, and it's not even Halloween, It's feels just like Christmas to me!
Here's why SOS rocks.
- It's cross plaform, written in Java.
- It's fast, small...kinda like Flash
- It's can use RegExp to search through the logs.
- It can talk birectionally to the content, and react.
- It can read the trace logs of the debug player...even when compiling normally in Flash
- It has colorizing and folding of messages.
Here's my favorite reason. Normally when using Flash you have to compile in order to see the trace output. But sometimes debugging it's trying different things, and you don't really need to recompile, just retest different things. Often in more complicated projects, compiling, with all the fonts and assets takes a long time. With Flash's trace output, you can't see it unless you compile again. With SOS setup to view the trace log ...you can.
Since it's socket based, it can help with a swf running from anywhere. But for using the socket debugger you need help.
There are a few AS libaries to make SOS more friendly. This FDT post covers one of them.
The troyworks framework has an TraceAdapter which I prefer and use. It's pretty easy to use, in fact it's injectable and can be turned back to the normal trace with a single commenting of a line.
A test case which shows all the features it supports is here
What it does is introspect the string passed to the trace to look for certain fields. One of my favorite is the ability for SOS to color highlight lines.
-
-
public function traceOutputTests():void{
-
trace("number " + 1);
-
trace("string" + new String("HelloWorld"));
-
trace("error " + "error message"); //won't work
-
trace("ERROR " + "error message2"); //will work
-
trace("WARNING " + "warning message");
-
trace("INFO " + "info message");
-
trace("HIGHLIGHT " + "highlight message");
-
trace("\\\\\\\\\\\\\\\\ " + "start section message");
-
var _ary : Array = ["A","B","C","D"];
-
trace("array1 " + _ary);
-
trace("array2 " + util.Trace.me(_ary, "Array2", true)); //shows code folding
-
trace("////////////////// " + "end section message");
-
-
}
-
Getting setup with SOS is pretty easy, just download and start it up (if you have java installed), but to get it to work with the normal trace() output you may have to follow these instructions primarily getting the flash debugger installed and coordinating where the debug log is created.
Using TraceAdapter with SOS
Past that you have to override the trace function. You can do it at a class level like
-
-
public var trace:Function = TraceAdapter.SOSTracer;
-
Then to set it back do
-
-
public var trace:Function = TraceAdapter.NormalTracer;
-
or
-
-
//public var trace:Function = TraceAdapter.SOSTracer;
-
I prefer setting it once early on like
-
-
TraceAdapter.CurrentTracer = TraceAdapter.SOSTracer;
-
And then have other classes use that reference, which centralizes configuration, during initiailzation. (Though will not update all references a 2nd time)
-
-
public var trace:Function = TraceAdapter.SOSTracer;
-
The only thing I've found using it, is that it does seem (along with Eclipse) to need lots of RAM and CPU. Periodically I assume to memory leaks or fragmentation in garbage collection I find I have to cose down both SOS and Eclipse. Also if I'm not doing lots of debugging I find that SOS consumes significant CPU when it's idling, waiting for connections, so I shut it down.
Flash: fl.managers:FocusManager could not be found FIX
Got these compiler errors compiling a document level script only movie, that didn't use any components. That had an import statement like
-
-
import fl.managers.FocusManager;
-
var fm : FocusManager;
-
fm = new FocusManager(view);
-
fm.activate();
-
You would think that would work, however when compiling it gives these errors:
1046:Type was not found or was not a compile-time constant: FocusManager
1180:Call to a possibly undefined method FocusManager
1172: Definition fl.managers:FocusManager could not be found
The last is the key to solving it, it means that despite the import request, the compiler can't find anything else to go with it. Meaning that it's not actually there!
Solution
The solution is easy. Take any interactive component (Label, Button are smallest), from the components library, drag it to the stage, then delete it from the stage. At this point the library will have a bunch of stuff for that particularly component, hidden within (likely the CompiledClip, "ComponentShim") is the appropriate magic to get FocusManager. Then recompile..should be fine.
Flash CS3: Debugging getting line numbers.
It's helpful in debugging code to get the line number and the name of the file. This is easy if your using the MXML compiler, via the -verbose-stacktraces and -debug but what about using Flash CS3? At least on my system by default null errors during runtime look like:
Error #1069: Property null not found on ...your class and there is no default value
at com.yourclass.::MyClass$someFunction()
Which isn't particularly easy to trouble shoot. But if you go File>Publish Settings and checkmark Permit Debugging you can get the far more useful, where 138 is the line number
at com.yourclass::MyClass$someFunction()[C:\\com\yourclass\MyClass.as:138]
