background preloader

Reduce swf size

Facebook Twitter

Analyze the size of a SWF built in Flex. Link Report visualizer. The Flex compiler has a rarely used feature called “link-report”.

Link Report visualizer

Using this option instructs the compiler to create a report of all symbols that went into the compiled application as well as a list of all external references. The Reducing SWF file sizes livedocs-page has more information about link reports. To enable it, you would either modify your Flex projects’ compiler settings: or you would use “-link-report output.xml” as an option on the mxmlc command line. In either case, an XML file with all definitions will be created after the compiler successfully built the SWF-file. The contents of the link report file look like this: Hmmm – not very easy to digest by just reading the file in a text-editor. I created an AIR application which can read, digest and visualize link-report files.

The neatest feature of LinkReportAIR is the little treemap (using ILOG Elixir) that is automatically created from the data in the link report. Using SwfxPrinter. April 8, 2007 on 12:35 am | In Flex, Programming, Uncategorized | 15 Comments It’s apparently a well-kept secret, but the Flex SDK includes a very useful tool for examining the structure and contents of SWF files.

Using SwfxPrinter

The Java class flash.swf.tools.SwfxPrinter, which lives in the Flex 2 SDK’s lib/swfkit.jar library, is an undocumented utility that dumps AS3 SWF files as XML documents. These dumps can provide really useful insight into what is taking up space in a compiled AS3 Flash or Flex application. If you’re in the FLEX_HOME/lib directory you can run it as follows: java -classpath asc.jar;swfkit.jar flash.swf.tools.SwfxPrinter [options] swfFilename Here’s a somewhat random excerpt from some output; this includes some Flash sprite definitions: The valuable -showoffset option causes the output to include the offset and size of each element in the file. Compiler options. Improving SWF Compression. Hrrrrrngh!

Saving from 1% to 3% when compressing the zlib compression of swf. – nicolas

Intro With web games you want hits — lot's of hits. A million per month or more if possible. Of course this means lots of traffic. While broadband became faster and cheaper during the last couple of years, traffic is still somewhat expensive. As you might have guessed I'm about to tackle the former with brute processing power. By the way this is the first part of a small series of articles. The SWF file format The SWF file format uses ZLib streams, which are basically the same kind of Deflate streams we can see everywhere. How to reduce SWF filesize ? SecureSWF. Make your Flash apps lean and mean and blazing fast.

Maybe good to obfuscate the code, but I gained only 1% size. – nicolas
$100 to $400 with: * Compacts SWF tags headers * Removes duplicate not-instructions * Removes duplicate export tags * Removes dead code blocks * Removes debugging information * Optimizes control flow statements by reducing the number of branches in the code. – nicolas

Put overweight ActionScript on a diet and gives users a snappier experience. secureSWF's optimization includes both ActionScript and file assets.

secureSWF

Optimize for better performance and smaller file size. ActionScript Optimization Code the way that works for you, then leave it to secureSWF to refine your ActionScript for performance. Method Inlining Inlining short methods will boost your code performance. Byte Code Optimization Byte code refers to binary compiled code blocks within your SWF files. Whichever settings you have used when compiling, you can use secureSWF to optimize your app for publishing. Class Optimization When coding, you probably have left a few class members set as public or protected members but have not used them outside the class. Code the way you want, and leave it to secureSWF to optimize your ActionScript classes. Instructions Optimization. "the most reliable" Flash Optimizer. SWFTOOLS. Swfextract. Current Stable swfextract man page Current Git Usage: swfextract [-v] [-n name] [-ijf ids] file.swf Available Options -v , --verbose Be more verbose -o , --output filename set output filename -V , --version Print program version and exit SWF Sub-element extraction: -n , --name name instance name of the object (SWF Define) to extract -i , --id ID ID of the object, shape or movieclip to extract -f , --frame frames frame numbers to extract -w , --hollow hollow mode: don't remove empty frames (use with -f) -P , --placeobject Insert original placeobject into output file (use with -i) SWF Font/Text extraction: -F , --font ID Extract font(s) Picture extraction: -j , --jpeg ID Extract JPEG picture(s) -p , --pngs ID Extract PNG picture(s) Sound extraction: -m , --mp3 Extract main mp3 stream -s , --sound ID Extract Sound(s) Extract all: -a Extract all files --outputformat "extract_%06d.

Swfextract

%s" Filename to use for extraction (printf format) How to use it To extract everything use... [1] Run using.

Optimize with haXe


  1. alain Dec 8 2010
    salut seb, merci, and welcome to the team