Reduce size of swf from Flash Builder - apache-flex

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

Related

Flex - Source Size vs. Compile Size

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.

Exporting release build - Flex through Intellij Idea

How do I generate release build of my Flex Application
through IntelliJ Idea, like I do in Flex Builder?
Right click on any project and select module setting.
Select tab "Flex compiler setting"
Last field on this tab is "Additional compiler options:"
add "-debug=false" without double quotes to it.
Do this for all the subprojects. (From this form only you can choose different projects).
do a project Rebuild and you will get a smaller swf.
Only problem is you need to keep separate project files for debug and release build, but thats ok, as you release builds are done rarely.
Alternate answer:
Instead of creating a Flex Module, create a Java Module, and add 2 Flex Facet's to it. One facet will be configured as the debug facet, the other as the release facet. This process will create 2 swf files, debug and release versions.
Create a java module, for example "FlexHelloWorld". Do not add a flex facet yet.
In the project view, right click on the project and select module setting
Under the Modules option, select the "FlexHelloWorld" module
Click the "+" symbol, add Flex Facet
Rename facet to "Debug"
Enter your main class name
Enter "debug.swf" as the output file name
Click apply
Click the "+" symbol, add Flex Facet
Rename facet to "Release"
Enter your main class name
Enter "release.swf" as the output file name
Under additional compiler options, add "-debug=false -optimize=true"
Click ok
Build the module. In the output directory, you will have "debug.swf" and "release.swf" files.
Note: In your HTML wrapper, you will have to call either debug.swf or release.swf. Or you could create 2 wrappers.
Does IntelliJ support Ant? Maybe not the answer you're looking for, but you could use the Flex Ant Tasks to build outside of FB.
http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html

How can I access data from a .fla file using Actionscript 3, Flex 4 SDK, and FlashDevelop?

Someone sent me a .fla file containing several art assets, with instances all configured to be displayed properly and in the right positions. However, since I'm using FlashDevelop with the Flex 4 SDK, I have no idea how to access these instances in code. Some of the objects are MovieClips that I need to modify the size of, and others are Dynamic Text objects that I need to change the display strings of at runtime.
If you have access to Flash (as in the development tool) you can right-click on a MovieClip in the library and select "Export SWC file".
The SWC file will contain all of the elements that have the "Export for ActionScript" property enabled. Place this SWC file on your classpath and FlashDevelop will tell the Flex SDK to link against it when building your final SWF.
If you don't have access to Flash to export the SWC you will need to get the other person to export the SWC file for you - you can't link against the FLA directly.
There's no obvious solution to this. basically, you will have to traverse the display list to find them, using numChildren, getChildAt etc. if you're lucky, they are named and you can use getChildByName.
greetz
back2dos

flex4 sdk in flexbuilder3, debugger partially works

If I changed used in one of my project sdk to current sdk4 beta, set breakpoint and stop on them every occurrences of mx.* packages are labeled "[no source]". Is known any trick to fix this issue?
Not sure why Flex Builder isn't figuring it out by itself, but you can manually set the source path of any swc on the library path (you have to do this for each project):
Right-click on the project, Properties
Flex Build Path property page
Library Path tab
Expand the "Flex 4.0" node at the top, then expand the swc that you want to attach source to
Double-click the "Source attachment" line, and specify the root dir of the source, e.g. C:\...\mysdk\frameworks\projects\framework\src

FlashDevelop - Why does code-completion not work with mx.controls

Today's my first day with Flex and FlashDevelop. In my ActionScript file, I have this line.
import flash.display.SimpleButton;
FlashDevelop is aware about this and Code-completion works fine.
But, when I have this line.
import mx.controls.Button;
Then code-completion doesn't work.
Works perfectly well for me w/o doing anything special. But maybe your project's properties got borked. Do this:
Open Project Properties
Go to Compiler Options tab
In Advanced -> Intrinsic Libraries add the following
Library\AS3\frameworks\Flex3
I had the same problem. Your AS3 class path is pointing at a directory to low in the flashdevelop library folder structure to pick the mx class prototypes.
1.) Within Flashdevelop press F10 to open the 'Settings' window.
2.) In the list on the left click on the 'AS3Context' option.
3.) Imediately Under the group title of 'Language' on the right hand side of the window, find the 'AS3 Classpath' option. Its value is typically set to 'Library\AS3\Intrinsic'. Change the the 'AS3 Classpath' value to read 'Library\AS3'.
4.) FIXED. Flashdevelop should now be aware of the mx libraries, thus autocomplete should now also work.
To include any swc to code complete, add it's parent folder to the swc libraries option. Some people claim that using intrinsic libraries works, but it didn't for me. Here's the paths to both settings:
ProjectSettings->CompilerOptions->SWCLibraries = {path to FOLDER containing swc's}
ProjectSettings->CompilerOptions->IntrinsicLibraries = {path to same FOLDER containing swc's}
It seems like you are missing the Flex framework in your build path. Have you looked at the libraries being included?

Resources