1 Reply Latest reply on Dec 15, 2011 1:36 AM by flexercised

    A really simple XML Question

    QuadWord

      i want to use XML to save some configuration for elements in my app.

      in my example i want to add 6 additional configuration sets to one "main" XML. each set can be config1 or config2.

      In this case i added 3x config1 and 3x config2. if i trace my results i do not only get the wrong order of elements but also some "strange" binding behavior.

      Of course this is a simplified example. my configuration sets are more complex (this is why i use seperate xml-objects for each config).

       

      Can someone tell me how this is supposed to work ?

       

      thanks,

      quadword

       

      <?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" applicationDPI="160" creationComplete="init();">

       

        <fx:Declarations>

       

        <fx:XML id="mainConfig" format="e4x">

                <allConfigSets>

                          <viewconfig>Baseconfig</viewconfig>

                </allConfigSets>

        </fx:XML>

       

        <fx:XML id="configSet1" format="e4x">

                <configSet><viewconfig>Set1</viewconfig></configSet>

        </fx:XML>

       

        <fx:XML id="configSet2" format="e4x">

                <configSet><viewconfig>Set2</viewconfig></configSet>

        </fx:XML>

       

        </fx:Declarations>

       

        <fx:Script>

                          <![CDATA[

                                    private function init(): void {

       

                                              mainConfig.appendChild(configSet1.viewconfig);

                                              mainConfig.appendChild(configSet1.viewconfig);

                                              mainConfig.appendChild(configSet1.viewconfig);

                                              mainConfig.appendChild(configSet2.viewconfig);

                                              mainConfig.appendChild(configSet2.viewconfig);

                                              mainConfig.appendChild(configSet2.viewconfig);

       

                                              // trace1 (see below): trace shows wrong order of elements

                                              trace (mainConfig);

       

                                              // trace2:(see below): changing data on original configSet seems to bind into mainConfig

                                              configSet1.viewconfig = "-";

                                              trace (mainConfig);

                                    }

                          ]]>

        </fx:Script>

      </s:Application>

       

      Trace1:

      <allConfigSets>

        <viewconfig>Baseconfig</viewconfig>

        <viewconfig>Set1</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>Set1</viewconfig>

        <viewconfig>Set1</viewconfig>

      </allConfigSets>

       

      Trace2:

      <allConfigSets>

        <viewconfig>Baseconfig</viewconfig>

        <viewconfig>-</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>Set2</viewconfig>

        <viewconfig>-</viewconfig>

        <viewconfig>-</viewconfig>

      </allConfigSets>