FlexCover Startup Problem

April 30, 2009 16:09 by docbliny 

If you get the error “Another program has already opened a LocalConnection with id ‘_flexcover’. No coverage data will be recorded.”, do the following:

  1. Open Task Manager and kill any instances of CoverageViewer.exe (or your Mac equivalent).
  2. Close all browsers.
  3. Close FlexBuilder.
  4. Close Yahoo! Messenger (or other client that hosts the Flash Player).

#3 did it for me.

I was using FlexCover 0.81.

Using the FlexBuilder "-link-report" compiler option to generate ActionScript size report

October 13, 2008 12:42 by docbliny 

I'm working on a pretty cool ActionScript 3 based project and we're trying to optimize the size as much as possible. Pretty much everything is rendered in code and we noticed that the AS compiler is actually pretty bad at optimizing the SWF. For example, it seems to not touch class level private variable names, thus keeping the actual strings intact which increases both the SWF size and memory usage pretty drastically if there are lots of instances of the object in memory. I don't have any hard numbers to share, maybe I'll get around to creating a sample project to get some numbers I can share.

Setting Compiler Options 

In the meantime, you can at least get a sense of where the size of the SWF is coming from by using the -link-report [filename] compiler argument. In FlexBuilder, you can set it under the ActionScript Compiler page in the Additional compiler arguments field.

Link Report File 

The resulting XML file contains a list of all ActionScript files, their size, optimized size and a list of all dependencies. For example:

script name="Drive:\Path\MyProject\src\accessibility\ComboBoxItemAccessibility.as" mod="1217893038671" size="1593" optimizedsize="875">
       <def id="accessibility:ComboBoxItemAccessibility" />
pre id="accessibility:ButtonAccessibility" />
       <dep id="flash.events:MouseEvent" />
dep id="accessibility:Constants" />
       <dep id="MenuItem" />
dep id="AS3" />

The most interesting items are the size and optimizedsize attributes.

Using an XSLT File to Improve Readability

The link report file can be pretty large and hard to read, so I put together a really crude XSLT file to transform the report into HTML. You can then easily drop the HTML file on Excel to sort by the size and see which classes might be good candidates to optimize.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="html" indent="yes"/>     <xsl:template match="@* | node()">
     <xsl:apply-templates select="@* | node()"/>

    <xsl:template match="/">
          <h2>ActionScript Link Report</h2>
          <table border="1">
               <th align="left">Name</th>
               <th align="left">Size</th>
               <th align="left">Optimized Size</th>
            <xsl:for-each select="report/scripts/script">
               <td><xsl:value-of select="@name"/></td>
               <td><xsl:value-of select="@size"/></td>
               <td><xsl:value-of select="@optimizedsize"/></td>