Archives for: April 2004, 01

04/01/04

Permalink 07:35:56 pm, Categories: Flash

logging Flash trace() output to a text file - thanks Flex docs!

another fine, fine nugget from the Flex documentation is how to use a config file to save trace output to a text file on your development machine using the Debug player!

this cfg file is a different cfg file than the one to disable auto-update and windowless movies from playing - that one is MMS.CFG and resides in the system folder.

this one is MM.CFG and resides in the home directory of the current user (eg: C:\Documents and Settings\username).

sorry Mac folks, this one seems to be a Windows-only tool.

anyways, here are the steps i took to get this working in WinXP. it's pretty much the same as on the referenced doc page, but i'll cover a few issues i encountered.

  1. right-click on the "My Computer" icon on the Windows XP desktop and select Properties to open the "System Properties" dialog
     
  2. click the Advanced tab
     
  3. click the Environment Variables button
     
  4. add the following environment variables to the User Variables (not the System ones)
     
    1. HOMEDRIVE with a value of "C:" (no quotes)
    2. HOMEPATH with a value of "Documents and Settingsusername" (again no quotes and use your username)
       
  5. navigate to the C:\Documents and Settings\username folder and create a new text file named "mm.cfg"
     
  6. open the text file and add the following:
     
    ErrorReportingEnable=1
    TraceOutputFileEnable=1
    TraceOutputFileName=C:\flashlog.txt

     
  7. next, navigate to your Flash program debug player directory (eg: C:\Program Files\Macromedia\Flash MX 2004\players\debug)
     
  8. double-click the "Install Flash Player 7 AX.exe" app - this will install the Debug version of the Flash player
     
    Note - this is where i had some problems. i had to actually go and download the Flash Player Uninstaller from MM's site and uninstall all players before being able to get the Debug player to actually kick in.
     
  9. open a web page with an SWF in it. if there is now a "Debugger" option in the context-menu, you have the Debug player installed. if not, try again, or try the uninstaller as i mentioned above.
     
  10. NOW - open Flash MX 2004
     
  11. make a new FLA
     
  12. add the following AS to the Actions panel:
     
    trace("hello from Flash"); // or some other goofy test thing
     
  13. publish your movie and open the HTML page in IE
     
    note that i did have "Enable Debugging" enabled, but i don't think that matters. if you try this without that setting and it doesn't work, try publishing again with this enabled...
     
  14. open Windows Explorer and look in the root of C:\ - there should be a flashlog.txt file (if not, check all the settings above and perhaps log-out and log back in, or reboot and try it again)
     
  15. open the flashlog.txt file and you should see your "hello from Flash" line in it!

MAJOR WOOT!

i was kind-of annoyed that enableDebugConsole() no longer worked in FP7 because it was a blessing for testing a file in the browser, but this is the next best thing! (i mean, of course there's still remote debugging with Flash open, but that's just not as cool as this)

since this requires the Debug player and a manual configuration file to be added to the system, it's not really feasible to use this method for any sort of actual text file writing from the browser. i mean, you can access the mm.cfg file, close all browser windows, re-open the browser, re-launch your page, and then trace to a different file. if you could do that, you could just write to a file in the first place! :-)

good luck! and happy tracing!

UPDATE!!! i've found that the flashlog.txt file is overwritten by each different Flash movie that is run. so you don't really have to worry about clearing out the file every-so-often. that could be a good thing, it could be a bad thing - depends upon what you're hoping it will do.

cheers
g.

Permalink

Search

Misc

Syndicate this blog XML

What is RSS?

The opinions expressed on this blog are those of the author only and are not necessarily those of his employer.

Creative Commons License
This work is licensed under a
Creative Commons License.

powered by
b2evolution