Stop Coding!

The Unofficial Flex Compiler Blog

I Don’t See These Tricks In fcsh!

with 4 comments

In one of my previous posts, Flex Compiler SHell (fcsh), I mentioned that Flex removed the flex2.tools.Shell class from mxmlc.jar in version 3. For those who’ve read my previous post, flex2.tools.SimpleShell is a simplified version of flex2.tools.Shell and is currently the ‘official’ fcsh. But flex2.tools.Shell is the version I used back then when I worked for Adobe. This does a lot more and I believe you will find that useful. So let me give you a demo here.

I’m going to use the ‘checkinapp’ application in my demo. It is located at flex/sdk/branches/3.0.x/frameworks/tests/checkinapp.

Adobe Flex Compiler SHell (fcsh) Version 3.0.0
Copyright (c) 2006 Adobe Systems Incorporated. All rights reserved.

(fcsh) mxmlc -debug=true -optimize=false checkinapp.mxml
fcsh: Assigned 1 as the compile target id
Loading configuration file frameworks/flex-config.xml
checkinapp/checkinapp.swf (756154 bytes)

To see the dependencies of checkinapp.mxml, we use the ‘dependency’ command. The number ‘1’ is the compile target id. “Top-level Definitions” means the definitions are visible externally to the file. “Inheritance” means they are the superclass and implementing interfaces. “Namespace” means they are the AS3 namespaces found in the application. “Types” means the listed definitions are found in the API signatures. “Expressions” are the definitions that are found elsewhere in the file, e.g. method bodies.

(fcsh) dependency 1 checkinapp.mxml
checkinapp/checkinapp.mxml
===Top-level Definitions===
checkinapp
===Inheritance===
mx.binding:IBindingClient
mx.core:Application
flash.events:IEventDispatcher
===Namespace===
AS3
mx.core:mx_internal
===Types===
mx.events:SliderEvent
ShoppingCart
PanelControl
ThumbnailView
Checkout
mx.styles:CSSStyleDeclaration
mx.utils:ObjectProxy
mx.events:FlexEvent
mx.containers:Panel
flash.events:Event
GridView
mx.effects:Dissolve
mx.containers:Canvas
mx.binding:IWatcherSetupUtil
mx.controls:Image
mx.containers:HBox
ProductDetail
mx.effects:Fade
flash.events:MouseEvent
CartView
mx.controls:HSlider
mx.events:ListEvent
mx.core:UIComponentDescriptor
mx.effects:Resize
mx.binding:Binding
mx.containers:ViewStack
ResizePanelEvent
===Expressions===
mx.controls:LinkButton
_checkinappWatcherSetupUtil
mx.controls:Label
ShoppingCart
mx.controls:Button
mx.events:PropertyChangeEvent
mx.controls:Spacer
PanelControl
ThumbnailView
mx.styles:StyleManager
Checkout
checkinapp_thumbRoll
mx.styles:CSSStyleDeclaration
mx.utils:ObjectProxy
mx.containers:Panel
checkinapp_listRoll
GridView
checkinapp_thumbOff
mx.containers:Canvas
flash.net:navigateToURL
mx.controls:ComboBox
mx.controls:Image
checkinapp_listOn
flash.utils:getDefinitionByName
checkinapp__embed_mxml_assets_products_tg_logo_gif_1172660324
mx.containers:HBox
ProductDetail
mx.containers:VBox
CartView
mx.controls:HSlider
mx.core:UIComponentDescriptor
mx.effects:Resize
mx.containers:ControlBar
checkinapp_listOff
flash.net:URLRequest
mx.binding:Binding
mx.containers:ViewStack
checkinapp_thumbOn

To see the usage of mx.controls:Button, we use the “usage” command. For example, ScrollThumb uses Button as a superclass.

(fcsh) usage 1 mx.controls:Button
[expressions] checkinapp/checkinapp.mxml
[types] framework.swc(mx/controls/scrollClasses/ScrollBar)
[inheritance] framework.swc(mx/controls/scrollClasses/ScrollThumb)
[expressions] checkinapp/ProductDetail.mxml
[expressions] checkinapp/Checkout.mxml
[types] framework.swc(mx/containers/Panel)
[types] checkinapp/CartView.mxml
[types] framework.swc(mx/controls/NumericStepper)
[inheritance] framework.swc(mx/controls/sliderClasses/SliderThumb)
[inheritance] framework.swc(mx/controls/CheckBox)
[types] framework.swc(mx/containers/Accordion)
[types] framework.swc(mx/controls/ComboBase)
[inheritance] framework.swc(mx/controls/RadioButton)
[inheritance] framework.swc(mx/containers/accordionClasses/AccordionHeader)
[types] framework.swc(mx/controls/alertClasses/AlertForm)
[inheritance] framework.swc(mx/controls/LinkButton)
Found: 16

I think many of you have seen and tried the “-link-report” mxmlc command-line option. Personally, I don’t use it because the -link-report XML output could easily reach .5MB in size for even the smallest possible Flex applications. Also, fcsh is better because the “usage-dependency” combo allows you to traverse the dependency graph in either directions.

To see the number of ‘debuggable” lines, we use the “lines” command. The counts below exclude blank lines. Also, for MXML files, the counts do not count XML tag lines, only the lines in <mx:Script>. The most interesting number below, IMO, is the size of the autogenerated code – the percentage is pretty high. The autogenerated codes are mainly for MXML components (e.g. data binding, styles, etc). That tells you one thing: if you were to write those MXML components in AS3, not in MXML, you would have to write a whole lot more. On the other hand, of course, one could argue that the compiler should autogen as little as possible.

(fcsh) lines 1
188 checkinapp/CartView.mxml
697 checkinapp/Checkout.mxml
26 checkinapp/CreditCardPicker.mxml
87 checkinapp/GridView.mxml
129 checkinapp/PanelControl.mxml
191 checkinapp/ProductDetail.mxml
151 checkinapp/ProductThumbnail.mxml
8 checkinapp/ResizePanelEvent.as
27 checkinapp/ShoppingCart.as
325 checkinapp/StatePicker.mxml
106 checkinapp/ThumbnailView.mxml
649 checkinapp/checkinapp.mxml
total number of lines in the source files: 2584
total number of lines in the autogen files: 1424

To see the bytecode size (in bytes) of the definitions, we use the “sizes” command. I’m listing only the top ten classes here. But you know there are hundred of classes in checkinapp.

(fcsh) sizes 1
104300 framework.swc(mx/controls/listClasses/ListBase)
75913 framework.swc(mx/core/UIComponent)
62331 framework.swc(mx/controls/DataGrid)
47073 framework.swc(mx/core/Container)
39207 framework.swc(mx/controls/dataGridClasses/DataGridBase)
39010 framework.swc(mx/controls/listClasses/TileBase)
34284 framework.swc(mx/controls/List)
30588 framework.swc(mx/managers/SystemManager)
28816 checkinapp/checkinapp.mxml
27623 framework.swc(mx/controls/Button)

I think these fcsh commands should help you analyze your codes’ dependencies and sizes and should in turn, minimize your application’s size.

Advertisements

Written by Clement Wong

April 21, 2008 at 4:32 pm

Posted in fcsh, Technology

Tagged with , ,

4 Responses

Subscribe to comments with RSS.

  1. Thank you for showing us the demo version and the useful tips. I was not able to use flex2.tools.Shell but now with your knowledge I think I will make it. There should be more user like you who post their knowledge to share it with other user. Thank you very much!

    Flüge

    December 15, 2008 at 6:31 am

  2. I downloaded Flex 2.0.1 SDK Hotfix 3 and flex2.tools.Shell is nowhere to be found in mxmlc.jar either.

    Which version of the Flex 2.0.1 can I get this from?

    The version of fsch.jar found at http://labs.adobe.com/wiki/index.php/Flex_Compiler_Shell only has SimpleShell too…

    IT Staffing Guy

    March 13, 2009 at 7:55 pm

  3. I downloaded Flex 2.0.1 SDK Hotfix 3 and flex2.tools.Shell is nowhere to be found in mxmlc.jar either.

    Which version of the Flex 2.0.1 can I get this from?

    The version of fsch.jar found at labs.adobe.com/wiki/index.php/Flex_Compiler_Shell only has SimpleShell too…

    IT Staffing Guy

    March 13, 2009 at 7:56 pm

    • looks like flex2.tools.Shell was yanked before the whole thing was open source. I don’t know if I have a copy of that. I have to go search for it…

      Clement Wong

      September 25, 2009 at 4:38 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: