Debugging in local machine

It may be difficult to debug in a multiplayer virtual world development. Usually we can test the script by putting "trace" in the logic for debugging purpose and view the trace log in the Flash IDE. To debug a multiplayer virtual world, we often need two or more instances running in parallel. They will most probably be running in standalone Flash player or the web browser locally. We will discuss how to set up the Flash player to view the Flash trace log without the Flash IDE.

There is a method to read the trace log without using the Flash IDE. It requires the following files:

  • A debugger version of Flash player
  • mm.cfg file
  • flashlog.txt

Downloading the latest debugger version of Flash player

The default Flash player installed in OS is a normal version without the debug feature. We need the debugger version of Flash player to output the trace log outside the Flash IDE. We will download and install the debugger version of Flash player by going to the following URL in the browser: http://www.adobe.com/support/flashplayer/downloads.html.

Downloading the latest debugger version of Flash player

The link to the debugger version is about one page below the Flash player download web page. Scroll down and find the title "Adobe Flash Player 10 - Debugger Versions (aka debug players or content debuggers)".

For a Windows user, download the "Windows Flash Player 10 ActiveX control content debugger (for IE)" and the "Windows Flash Player 10 Plugin content debugger (for Netscape-compatible browsers)".

For a Mac user, download the "Macintosh Flash Player 10 Plugin content debugger (Intel-based Macs)" if you are using the Intel-based Macintosh.

If you are using the PowerPC-based Mac, unfortunately the latest Flash player 10 updates dropped the support for PowerPC-based Macs, but you can still download the "Macintosh Flash Player 9 Plugin content debugger (PowerPC-based Macs)". All the examples in the book work well on Flash Player 9.

For a Linux user, download the "Flash Player 10 Linux debugger and standalone players".

  • Double-click the installer and install the Debugger Flash player with default settings.

Creating the mm.cfg file

The mm.cfg file configures how the Debugger Flash player behaves.

  1. Create a new file in your favorite pure text editor and name it mm.cfg.
  2. Write these two lines in the file:
    ErrorReportingEnable=1
    TraceOutputFileEnable=1
    

These two lines tell the Flash player debugger to output any error and trace into the logfile.

For Windows XP user, save the file into:

C:Documents and Settingsusernamemm.cfg

For Windows Vista and Windows 7 user, save the file into:

C:Usersusernamemm.cfg

For Macintosh user, save the file into:

/Library/Application Support/Macromedia/mm.cfg

For Linux User, save the file into:

/home/username/mm.cfg

Testing the debugger log

We will create a simple Flash file to trace something and read it.

  1. Launch Adobe Flash.
  2. Create a new Flash document — File | New | Flash File (ActionScritp 3.0).
  3. Add some trace commands as the action in frame 1 in order to test the logging.
    trace("Testing Trace without Flash IDE");
    
  4. Publish the Flash to make the SWF file and HTML file.
  5. Open the newly created HTML file. You may see nothing but the trace should be working and we need to open the trace logfile to confirm it.

Locating the Flash log output file

After setting up the Flash player debugger and running the trace command, a file called flashlog.txt is created.

The default location of the flashlog.txt:

  1. In Windows XP: C:Documents and SettingsusernameApplication DataMacromediaFlash PlayerLogsflashlog.txt.
  2. In Windows Vista or Windows 7: C:UsersusernameAppDataRoamingMacromediaFlash PlayerLogsflashlog.txt.
  3. In Mac OSX: /Users/username/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt.
  4. In Linux: /home/username/Macromedia/Flash_Player/Logs/flashlog.txt.

Reading the Flash logfile

The simple way to read the Flash logfile is to open the flashlog.txt directly. We should see the "Testing Trace without Flash IDE" in the flashlog.txt file.

However, it is not convenient to debug because the opened flashlog.txt file does not reload automatically when the Flash traces a new output. There are different methods to read the Flash logfile in a better way.

Open the flashlog.txt in web browser

Instead of opening the Flash logfile directly, we can drag the file into a web browser. We can then refresh the browser every time there is an update from trace output.

Using a Firefox add-on to read the Flash logfile

There are some Firefox add-ons that can read the trace file as a sidebar within Firefox.

Reading the log with FlashTracer

FlashTracer can display the trace logfile as a sidebar in Firefox.

  1. Go to http://www.sephiroth.it/firefox/flashtracer/ on the Firefox web browser.
  2. Click on Install now in the Install section of that web page.
  3. Click on Allow if a yellow bar appear stating that Firefox prevented the site to install the software.
  4. Confirm the name as flashtracer.xpi.
  5. Click on Install Now.
  6. Click on Restart Firefox to restart Firefox and complete the installation.
  7. In the Firefox menu, choose Tools | Flash Tracer to open the Flash Tracer panel.
  8. Click the preference icon to open the preference panel.
  9. Click on Browse in the Select output file section in the General Settings tab.
  10. 10 Choose the flashlog.txt file we just opened.
  11. Click on Yes if a dialog pops up to ask if you want to replace the flashlog.txt.
  12. Click on OK to confirm and exit the preference panel.

After setting up the Flash Tracer add-on, we can now view the Flash trace output directly in browser while debugging our code.

Reading the log with FlashTracer
Reading the log with FlashTracer

Reading the log with FlashBug

Firebug is a Firefox add-on for web developers to inspect different information from the opened web page. FlashBug is another add-on that adds a Flash Console tab into Firebug to display the Flash trace logfile.

  1. Go to the Firebug website http://getfirebug.com/ in the Firefox web browser.
  2. Click on the Install Firebug For Firefox button to start the add-on installation.
  3. Click on Allow if a yellow bar appears stating that Firefox prevented the site to install the software.
  4. Click on Install Now.
  5. Click on Restart Firefox to restart Firefox and complete the installation.
  6. Go to the Flashbug add-on page after Firefox restarts https://addons.mozilla.org/en-US/firefox/addon/14465/.
  7. Click on the Add to Firefox button to install the add-on.
  8. Click on Install Now to proceed.
  9. Restart the Firefox after the installation completes.
  10. Click on the Firebug icon in bottom-right of Firefox to open the Firebug panel.
  11. Choose Flash Console tab and click the drop-down arrow button.
  12. Enable the FlashBug by choosing Enabled.
  13. The flashlog.txt is auto-configured and displayed in the panel.

FlashBug provides some more bonus features than FlashTracer. It cannot only read the trace log but also inspects the list of stored Shared Object data. Shared Object is some data that is stored locally, similar to cookies. The same Flash document can access it and save/load the stored data locally.

Reading the log with FlashBug

"Tail" the trace log file in terminal

In Linux and Mac, we can read the Flashlog file in terminal by executing the following command:

For Mac OSX:

tail -f "/Users/{username}/Library/Preferences/Macromedia/Flash Player/
Logs/flashlog.txt"

For Linux:

tail -f "/home/{username}/Macromedia/Flash_Player/Logs/flashlog.txt"

The tail command reads the files until the end of the file.

The -f parameter lets the tail command to keep refreshing for new Flash log output.

This is a convenient way to keep reading the latest trace logfile without Firefox.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.124.40