Sometimes you need to check what's happening under the hood while your Flash file is live online. One method to do this is to simply create a dynamic text field and then write debug text to that as required.
Another method which is a bit cleaner imo is to use the Flash Remoting NetDebugger. There's a handy panel that comes with this called the NetConnection Debugger. If you're using Flash Remoting already then you can use this panel to see what data is getting sent in and out of Flash. Another function of it is to accept remote trace calls. That last bit is what we're after here. It's very easy to implement, as in 4 lines of code to implement.
Step 1. Download and install the Flash Remoting files if you haven't go them already. You can get them
here. If you have Flash CS3 then checkout some of the results from
this google search to see your options.
Step 2. Stick this at the top of your main Flash file:
Code:
import mx.remoting.debug.NetDebug;
NetDebug.initialize();
That imports the relevant classes and then initialises the debugger.
Step 3. On the main menu in the Flash IDE head over to Window->Other Panels->NetConnection Debugger. That should open the debugger window.
Step 4. Use the debugger. To trace from an online Flash file you just have to stick this code in the section you want to trace from:
Code:
NetDebug.trace("I'm being traced!");
Note that if you're tracing from inside a class or another file that is not the one you put the code from Step 2 into then you'll need to add the same import statement (from Step 2) to the top of this second file, not the initialise line though.
Step 5. Try it out. Upload your Flash file, make sure you have the debugger open (Step 3) and then view the file with your browser. You should see the trace statement appear in the debugger.
The debugger is pretty cool when you're using Remoting as it can show the contents of arrays your passing amongst other things. I use it with AMFPHP to see what's going on in various places.
Edit:
The Flash help docs list these as two steps to do before the ones I listed. When I tested it I didn't have to do this and it still traced for me:
- From the Window menu in Flash, select Other Panels > Common Libraries > Remoting.
- From the Library panel, drag the RemotingDebugClasses library to the Stage.
Another handy thing the docs point out is that you can run the debugger outside the IDE by launching it's swf file directly:
Quote:
| Originally Posted by LiveDocs
For Windows:
C:\Program Files\Macromedia\Flash MX 2004\en\First Run\WindowSWF\
For Mac:
HD:Applications:Macromedia Flash MX 2004:First Run:WindowSWF:
|