2 Replies Latest reply on Aug 15, 2006 3:02 AM by DavidWhewell

    How to reduce the base footprint of Flex 2 applications

    DavidWhewell Level 1
      Hi everyone,

      To give you guys some context first, I'm software producer for a company that produces applications that are delivered online. We currently use Java and deliver the products over the web, they then talk back to our servers - it's mostly about parsing and interpreting streaming data. Java has its issues, so when Flex 2 and ActionScript 3.0 came along, I was very excited. At first ActionScript 3.0 seemed like a great platform for developing the application on, and I've been evaluating using either pure AS3.0 or Flex 2 for our next generation of products. I love the ease with which Flex allows you to develop front-end and the huge suite of ready-made components, however, I have a problem with the size of files it generates.

      While I can accept that the components Flex uses are generic and heavyweight, there also seems to be a very large footprint for even the simplest of applications! For instance:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Label text="Hello World!"/>
      </mx:Application>

      builds to a 110k swf file!! And that's not even the debug version, which is 175k!

      Conversely, a similar thing in pure ActionScript 3.0:

      package {
      import flash.display.Sprite;
      import flash.text.TextField;

      public class Hello_World extends Sprite{
      public function Hello_World(){
      var myText:TextField = new TextField();
      myText.text = "Hello World!";
      this.addChild(myText);
      }
      }
      }

      builds to a very respectable 400 bytes. So it's obviously not SWF as a format which is as fault, but Flex 2 is doing something mind-boggling.

      So my question is - is this correct? Am I doing something wrong which is causing these bloated file sizes? And if not, is there a way around this to make the download of built-in Flex components more manageable (is it possible to put standard MX components in an RSL for instance?) I don't mind a Panel taking 20k and a Datagrid 50k to download, but over 100k to begin with is a nasty shock which may push me away from using Flex 2, which would be a great pity.

      Thanks in advance for your time,

      David
        • 1. Re: How to reduce the base footprint of Flex 2 applications
          Flex harUI Adobe Employee
          That is correct. Think of the framework more like Microsoft Foundation Classes. If I write helloworld w/o MFC it is really small, but as soon as I use MFC, it gets big fast. You have to pay for the infrastructure somehow. Java isn't small either.

          So RSLs are like DLLs and so you can put the components in an RSL and therefore have several apps share it, but it has to get downloaded once, so at some point, somebody is going to have to download 110K. Also RSLs are per-domain so all of the apps have to be hosted from the same domain as the RSL. There is no way to pre-install the RSL either (unlike pre-installing Java on all target machines).

          Most of our end-users have high-speed internet and don't notice the 110K. Are your target customers on dial-up? Also, serious applications easily range into 100's of K so even if you cache the components the rest of the app might be slow to download on a slow connection.

          You might want to share some of your ideas on target download sizes and why your customers need that configuration (slow connections, slow computers, some other issue), so our product managers can consider your needs.

          Flash is streamed, so it turns out that you can start showing visuals way before the 110K of components comes down by customizing the preloader. You can't really start the app, although I suppose you could fake a login dialog, but you can certainly show startup progress and maybe give the user something to read or do.

          At any rate, we'd like to see if we can help you get around your size concerns, so please try to share more information about your needs on this forum. There are some related projects in the works at Adobe that might be better suited to a lightweight-install kind of configuration and those folks may want to work with you as well.
          • 2. Re: How to reduce the base footprint of Flex 2 applications
            DavidWhewell Level 1
            Hi Flex harUI,

            thanks for your message. unfortunately it does confirm my basic fears! we build a variety of different applications, though all concentrate on handling and displaying streaming data in some format or other (either tables of data, graphs based on the data, other derivative methods and so forth). some of these are obviously going to be heavyweight, at which point whether it's 500k or 5M doesn't really matter too much. however, some of them are very lightweight, so we would like to keep their size as small as possible.

            our backend (ie connecting to the streaming services, authenticating and so forth) is done in ActionScript classes, so builds nice and small. however, if i wanted to build a lightweight component in Flex that simply connected to this streaming service and displayed one variable updating in a textfield, it would still take about 110K. I've prototyped this entirely in ActionScript, and it fits inside 4K, which is obviously far better for a lightweight component.

            I guess it is possible to combine ActionScript front-ends for the lightweight components, and Flex for the heavyweight, but I was hoping Flex would be adaptive enough to not have such a huge overhead even when it looks like it's not contributing anything to the frontend.

            Which leads me onto my other question - would it be possible to RSL-ise these basic Flex components? ie the used mx.* classes (textfields, datagrids, and so forth) - if I had 10 different 4K applications, the first of which had to download 200K of Flex components that the other 9 would then re-use, that would not be as painful in the long run. Or is it only custom Flex components that are compilable into an RSL?

            Thanks again for your response,

            David