View unanswered posts | View active topics



Reply to topic  [ 5 posts ] 
Reducing the file size of a Flex App 
Author Message
Member

Joined: Sun Mar 15, 2009 6:56 pm
Posts: 1
Reply with quote
Hi,
I've noticed that even when I build the most simplest of applications like a basic ticker tape or even just a dummy app wtih a text box, a button and a label the file size of the swf is always around 300 KB. I find that very strange as I know you can easily build swf to be as small as 10-20 KB etc.

Is there something with the default libraries getting loaded or do I need to explicitly tell what libraries to import?
Like for example the code below complies to a 299 KB file. Any idea what could be going wrong.
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
   <mx:Script>
<![CDATA[

   // This is the actual Random(n) function
   private function Random(inputVal:int):int
   {
      var r:Number = (Math.random() * inputVal)+1;
   return r;
   }
// a Function thats  triggered by the button
   private function btnAction():void
   {
      var a:int = parseInt(enterText.text);
      var b:String= Random(a).toString();
   myVtext.text = b;
   }
   ]]>
</mx:Script>
<mx:Panel width="250" height="150" x="50" y="150" horizontalAlign="center" verticalAlign="center">
   <mx:TextInput x="150" id="enterText" enabled="true" text="Enter a Number" ></mx:TextInput>
   <mx:Label  x="150" id="myVtext" text="its null"></mx:Label>
   <mx:Button id="myButton" click="btnAction()" label="Generate Random Number"> </mx:Button>
   </mx:Panel>
</mx:Application>


Sun Mar 15, 2009 7:05 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
As soon as you are using an MXML file you bring in the largest part of the Flex components framework.

Framework caching gives you a chance to reduce the user loading time if the framework was already downloaded by your user:
viewtopic.php?f=9&t=3291
Problem is that your user will download the full 550kb of the framework if it wasn't in his cache.


Sun Mar 15, 2009 7:51 pm
Profile WWW
Member

Joined: Sun May 11, 2008 3:01 pm
Posts: 895
Reply with quote
Philippe is definitely right, because chances are 99 to 1 you'll be using mx.core.Application if you're using MXML. But producing big files isn't the mandatory "feature" of MXML itself. So far I've been able to use only the Binding classes + classes that Flex uses to handle assets (starting my apps of off flash.display.Sprite, like you'd do in a regular AS3 project, instead of Application). So far the minimum file size I was able to get was less then 10 - 15K, which is totally OK even for the ad, and still lets you use more compact MXML syntax + binding :)

_________________
http://www.couchsurfing.com/people/wvxvw


Mon Mar 16, 2009 12:03 am
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
wvxvw wrote:
Philippe is definitely right, because chances are 99 to 1 you'll be using mx.core.Application if you're using MXML. But producing big files isn't the mandatory "feature" of MXML itself. So far I've been able to use only the Binding classes + classes that Flex uses to handle assets (starting my apps of off flash.display.Sprite, like you'd do in a regular AS3 project, instead of Application). So far the minimum file size I was able to get was less then 10 - 15K, which is totally OK even for the ad, and still lets you use more compact MXML syntax + binding :)

Would be interesting to see a sample application like that :)


Mon Mar 16, 2009 9:00 am
Profile WWW
Member

Joined: Sun May 11, 2008 3:01 pm
Posts: 895
Reply with quote
http://code.google.com/p/e4xu/source/br ... /trunk/src
It is quite messy at the moment, but, it is rather a proof of concept than real project :)
The document MXML class would look something like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- FrameworlessDispatcher -->
<fl:Sprite
   xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:fl="flash.display.*"
   xmlns:e4xu="http://e4xu.googlecode.com"
   xmlns:tests="*"
   enterFrame="enterFrameHandler(event)">
   <mx:Script>
      <![CDATA[
         import flash.events.Event;
         import org.wvxvws.mxmlutils.MXMLHelper;
         import org.wvxvws.tests.TestEvent;
         
         private function enterFrameHandler(event:Event):void
         {
            var f:Function = MXMLHelper.nameForMXMLListener(this, Event.ENTER_FRAME);
            removeEventListener(Event.ENTER_FRAME, f);
            testDispatcher.emitEvent();
         }
      ]]>
   </mx:Script>
   
   <tests:TestMap/>
   
   <e4xu:Dispatcher
      id="testDispatcher"
      factory="{TestEvent}"
      type="{TestEvent.TEST}">
      
      <e4xu:eventProperties>
         <mx:Object>
            <mx:foo>bar</mx:foo>
         </mx:Object>
      </e4xu:eventProperties>
      
      <e4xu:constructorArguments>
         <mx:String>argument#1</mx:String>
         <mx:String>argument#2</mx:String>
      </e4xu:constructorArguments>
      
   </e4xu:Dispatcher>
</fl:Sprite>

_________________
http://www.couchsurfing.com/people/wvxvw


Mon Mar 16, 2009 10:49 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.