Set variables in MXML avoiding data binding?

I love MXML, but I'm starting to notice some of its flaws. The main problem I am facing is the use of more memory due to the need for binding. In the super-longitudinal code snippet below that I 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>

variables for mxml labels are set using either (a) magic numbers, (b) variables [Bindable], and (c) const. Interestingly, (at least for me) scenario (c) takes up more memory than (a) but less than (b) - I would assume that it will be equal to one of the two, and hoped that it would be the same as (a) but I do not think.

: MXML, ? , AS MXML , , .

: c a b? , , const , , , .

!

+3
1

, . , , , . " " , , .

, , , ( ). , , Flash . Flash , . :

var a:Object = {};
var b:Object = a;
// then a === b as in the same reference in memory (check it in debugger)
// However
var a:String = 'weee';
var b:String = a;
// Then a !== b since the String is duplicated in memory

, , ActionScript , (, "&" C Java ). , , . , , , , , ;)

" ", , , , , , String "" ( mxml ). , , ; , , , , , "" , .

, , , . , , , , :)

EDIT: , , MXML AS, ( " " ). , , ; . ActionScript mxml counterpart ( BindingUtils AS) .

+2

All Articles