If you get the error “Another program has already opened a LocalConnection with id ‘_flexcover’. No coverage data will be recorded.”, do the following:
- Open Task Manager and kill any instances of CoverageViewer.exe (or your Mac equivalent).
- Close all browsers.
- Close FlexBuilder.
- Close Yahoo! Messenger (or other client that hosts the Flash Player).
#3 did it for me.
I was using FlexCover 0.81.
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()"/>
<h2>ActionScript Link Report</h2>
<th align="left">Optimized Size</th>