I love MXML but am starting to notice some of its drawbacks. The main one I'm struggling with is its larger memory usage due to the need for binding. In the super simple code snippet below, which I've tested on Flex 4.0
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
[Bindable] private var xPos:Number = 20;
[Bindable] private var yPos:Number = 20;
[Bindable] private var testo:String = "hello";
[Bindable] private var colorVar:uint = 0x212122;
private const xPosConst:Number = 20;
private const yPosConst:Number = 20;
private const testoConst:String = "hello";
private const colorVarConst:uint = 0x212122;
]]>
</fx:Script>
<!-- <s:Label x="20" y="20" text="hello" color="0x212122"/>-->
<s:Label x="{xPos}" y="{yPos}" text="{testo}" color="{colorVar}"/>
<!-- <s:Label x="{xPosConst}" y="{yPosConst}" text="{testoConst}" color="{colorVarConst}"/>-->
</s:Application>
the variables for an mxml labels get set using either (a) magic numbers, (b) [Bindable] variables and (c) consts. Interestingly (to me at least) scenario (c) takes up more memory than (a) but less than (b) - I would have assumed it'd be equal to one of the two and was hoping it would be the same as (a) but I guess not.
My main question: is there any way to set variables in MXML that doesn't eat up memory? I'm aware that I can do this explicitly in AS and keep MXML as a bare bone structure but was wondering if there was an alternative path.
Secondary question: why memory usage in c different from a and b? I've looked up at the intermediate code and it seems like the const case still sets up some binding logic but not as much and have been wondering why that is.
thank you!