Determining the size of your Flex application

The following example shows how you can determine the total bytes of your Flex application by accessing the loaderInfo.bytesTotal property.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/10/29/determining-the-size-of-your-flex-application/ -->
<mx:Application name="loaderInfo_bytesTotal_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        applicationComplete="init();">

    <mx:Script>
        <![CDATA[
            private function init():void {
                var bTotal:uint = loaderInfo.bytesTotal;
                lbl.text = "bytesTotal: " + numberFormatter.format(bTotal);
            }
        ]]>
    </mx:Script>

    <mx:NumberFormatter id="numberFormatter" />

    <mx:Label id="lbl" />

</mx:Application>

View source is enabled in the following example.