Flex - Source Size vs. Compile Size - apache-flex

Could you explain why a Flash Builder source folder - no larger than 2 MB - compiles into a SWF exceeding 15 MB with debugging turned off (exported release build)?
There is only 1 embedded image at about 93k - no other images. The application is not that complicated, basically calls are made to a MySQL db to display information, as well as store information. I have used drop shadows and borders, but all standard to Flash Builder. Some custom classes and one custom skin.
Thank you...
Here is listing of the files:
.DS_Store
mx_4.5.1.21328.swz
Main.html
playerProductInstall.swf
Main.swf > 15 MB
rpc_4.5.1.21328.swz
amf_config.ini
services
assets
skins
charts_4.5.1.21328.swz
spark_4.5.1.21328.swz
framework_4.5.1.21328.swz
sparkskins_4.5.1.21328.swz
gateway.php
swfobject.js
history
textLayout_2.0.0.232.swz

This seems pretty large to me.
When you say "Debugging Turned Off" what does that mean? Did you export a release build? Or did you just press the "play" button to run your code instead of the "Debug" button?
Do you have the Flex Framework linkage type set to RSL (AKA External) or Merge into Code?
Are you using an external libraries (SWC)? A framework, such as RobotLegs or Swiz, could add to the size of the SWF; but will probably not be located in the source folder.

Well, well...thought I'd revisit this since I found the problem - a font in a css file with embed set to 'true'. This font wasn't even being used, so I removed it and the css file completely (not in use either). They probably got inserted way early in the project. Code now hovering around 1 MB and less than that for the export build. Hope this helps someone. Cheers!

Flex is a collection of ActionScript classes and components, so when you build an app based on Flex, some of these classes get embedded into your application.
Something as simple as a <s:Button means that the byte code of spark.components.Button has to be included into your application along with your custom code, it's not part of the runtime.

Related

How to check CSS loaded size in Angular Application

Hope you all doing great.
I am using SCSS and Bootstrap in my Angular Application and as we know once Angular app runs, it converts these SCSS files to CSS version of it.
How can I check CSS file size generated as a whole for application as I need to show some reports for optimization tasks.
Any idea. I tried googling and here on Stack Overflow but couldn't find required solution. I can't even see any CSS file in Network tabs of Browsers.
Any Suggestion?
Assuming you are using Angular CLI for your project, which uses webpack internally...
Once you build a project. A dist directory is generated in the project root. Take a look into it and you'll find all the .js and .css bundles it might have generated.
Note - The size will vary based on what kind of build you do. For a production build, the sizes are going to be minimal, for other kinds of builds, if any, the sizes may differ.
You should go first in the Networks tab then reload the page. Once you reload it, click on CSS filter then you would see all the list of CSS included in your app, with the file size.
I didnt find any css generated in Network like above answer but I did a trick.
I went to webpack folder and there I found one generated CSS. ( Searched through a random CSS Selecto ).
I right clicked and saved it on desktop. If you check the properties of this CSS file, it shows the size in KB.

Reduce size of swf from Flash Builder

I have created a simple Flash Builder 4.6 project containing a simple button, and i have exported the project with release option, with mx namespaces.
The problem is that the file size is aboud 266 kb with the compile option: Merged into the application. I use only a simple button. My question is there is a way to remove any reference to mx library that i don't use in my code in order to reduce the swf size.
The option "Merged into code" will actually already figure out what needs to be compiled into the application and strip out code that you don't use. As a test, try adding another different component and create another release build. You'll notice that the filesize is bigger.
The best way to reduce the swf size is to use Runtime shared libraries (RSLs). This is the default linkage option of the SDK.
http://livedocs.adobe.com/flex/3/html/help.html?content=projects_7.html
try this:
Project -> Properties -> Flex Build Path
Make sure the combo "Framework linkage" is selected with the value: 'Merged into the code'.
Below you should have a tree named "Build Path Libraries".
Expand the first node. Then try to remove the libraries by selecting the relative node and clicking on the Remove Button on the right

Setting up Flex / AIR project structure for a large number of images?

We build prototypes and demo applications in Flex 4.5.1 and AIR 2.7 for mobile and desktop use. These tend to involve a large number of full-screen .PNG files. Lately we have been looking at ways to segment our code for flexibility and multi-screen re-use.
What suggestions do people have for segmenting the project and libraries such that compile times are minimal and images are easy to replace?
A couple of strategies pop to mind:
Externalize the assets from in-line [Embed] statements, to using a CSS file.
Configure the CSS to compile as a seperate SWF, and load it at runtime. This should minimize the amount of PNG encoding the compiler is doing during your normal compilation process.
If that still doesn't speed it up enough (I've found that the incremental compiler sometimes gets mixed up and re-encoded the embedded assets, killing compiler speed), move the CSS files to a separate project altogether.
This option is preferable, as loading your images at runtime gives you better flexibility in your multi-screen projects.
Alternatively:
If using CSS isn't an option for some reason, move your [Embed]'s from your main project to a separate SWC project, and embed them on classes.
Add the swc as a dependant project
Reference the assets via the classes.
eg:
// assets-project/src/Images.as
public class Images {
[Embed('/assets/img/defaultAvatar.png')]
public static var defaultAvatar:Object;
}
// main-project/src/SomeView.mxml
<s:BitmapImage source="{Images.defaultAvatar"} />

Min. Flex Module size is ~30kb and contains Framework classes. How to remove them?

Compile the following module with all framework SWC-s excluded in release mode in Flex 4:
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"/>
The SWF size will be 35,658 bytes.
Now generate link report via -link-report for this SWF and load it via -load-externs. Size of the SWF now is 33.174 bytes.
If you check link report now, you will see that some framework classes like mx.modules:IModuleInfo or mx.utils:LoaderUtil are still there.
How to exclude them from SWF?
You are excluding framework SWCs by using RSLs, right?
If I had to guess, those classes are required by Modules and there is a reason for compiling them into the class. I'm sure Adobe was meticulous when creating RSLs and put a lot of thought into what should or should not be included in the main SWF.
I wonder why this is important, though. A 30K swf is really small.
The problem is that the standard components are not in the client runtime enviroment.
For example, in Flash with AS2 or AS3 if you use a ComboBox you have more than 20KB of overhead because the binaries for the component must be packed with your swf. This happend with Flex too. To make an small binary I used an small footprint library with the flash components, but this was for Flash AS2.
Good Luck.
I guess you have to dig through the link report. Find out which classes depend on mx.modules:IModuleInfo and mx.utils:LoaderUtil, and you're likely to understand how or why this happens.
It must be quite many classes, because the once mentioned including their dependencies have 6 KB raw and 2.8 KB optimized size.
greetz
back2dos

How about using FLEX 3 component inside Flash file?

Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ?
I know its possible in the opposite direction.
With my minimal testing it seems you can't use Flex components when building a "pure AS3" project. (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)
I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would instantiate and addChild one mx.controls.Button. I copied the whole mx package from the path mentioned by hasseg into the project source path.
This is what I found out:
By removing the use of mx_internal from a certain Version.as file, I got Flash IDE to compile my test project without warning. Nothing showed up on the stage though.
Using Flex Builder (and the flex compiler, obviously) I also managed to compile the project without errors. I put breakpoints in the code and watched it build itself in the debugger. The components were instantiated flawlessly, but still nothing showed up on the stage. This swf also crashed the browser numerous times.
I haven't used Flex code in a "pure AS3" project myself, but I don't see why you couldn't do that.
You can download the Flex SDK and get the Flex components from there, both as an swc file (under /frameworks/libs) and as AS3 source code (under /frameworks/projects/framework/src).
It looks like this can be done after all: http://labs.wichers.nu/2007/12/25/using-flex-compiled-code-within-flash/
In general you need to use MXML to initialise the Flex framework and use Flex components.
Mike Chambers from Adobe says:
There is not support for using the Flex Framework in an AS only project. While it is theoretically possible, you would have to manually bootstrap a lot of the application initialization code that Flex handles (something which would be rather complex). - Source
To see how complex, you can tell the compiler to keep the intermediate AS3 files that it generates from the MXML. Open your AS3 project properties and set -keep-generated-actionscript as an argument to the compiler. Compile your project then look in the obj/generated folder. Using Flex 4, I get 13 small files the main of which extends spark.components.Application and overrides a few methods.
So it's possible but you probably wouldn't want to do it. Flex is meant to make your life easier, not harder.

Resources