9 Replies Latest reply on Jan 11, 2010 11:37 AM by ACFlex

    Easy Question: XML in Flex

    lkenney2 Level 1

      I'm creating the UI for a player that has to be easily customizable. The position of the button is based on the type of client using the player, so I have an xml document that looks like this:


      <?xml version="1.0"?>
          <button position='btnPos1'>


      I then load the data from the xml file into the Flex .mxml file. I'm pretty sure the xml document is loaded correctly, and there are no problems with the build or at runtime, so why won't the buttons move to thwir places?


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" width="768"
                  import flash.net.URLLoader;
                  import flash.net.URLRequest;
                  import flash.xml.*;
                  private var xmlLoader:URLLoader = new URLLoader();
                  private var xmlData:XML = new XML();
                  private function init():void{
                      xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
                      xmlLoader.load(new URLRequest("unitConfig.xml"));
                  private function LoadXML(e:Event):void {
                      xmlData = new XML(e.target.data);


          <mx:TabNavigator width="600" height="400" id="tabNav">


              <s:NavigatorContent label="Listen &amp; Repeat" width="100%" height="100%" id="tbListenandRepeat">
                  <mx:Button id="btnLRRec" x="{xmlData.button[0].x}" y="{xmlData.button[0].y}" styleName="StoryRecord" enabled="true"/>
                  <mx:Button id="btnLRSkip" x="{xmlData.button[1].x}" y="{xmlData.button[1].y}" styleName="Skip" enabled="true"/>


              <!-- Place non-visual elements (e.g., services, value objects) here -->