3 Replies Latest reply on Jun 18, 2011 11:51 AM by Maxime Chupin

    Statique load of XML file with List choose

    Maxime Chupin Level 1

      Hi,

       

      So let me explain my problem:

      - I have some XML files: (in my <fx:Declaration>)
          <fx:XML id="flexang" source="xml/flex-ang.xml" />
          <fx:XML id="flexastro" source="xml/flex-astro.xml" />
          <fx:XML id="flexber" source="xml/flex-ber.xml" />

      - I have a List constructed as follows:

      (in my  <fx:Declaration>)

          <fx:Model id="anim">
            <states>
          <state label="Anguinéa" data="animations/flex-ang.swf"/>
          <state label="Mouvement rétrograde" data="animations/flex-astro.swf"/>
          <state label="Bielle de Bérard" data="animations/flex-ber.swf"/>
            </states>
          </fx:Model>


      (and then)

            <mx:List id="source" width="100%" color="blue"
                 dataProvider="{anim.state}"
                 change="selectedListItem = List(event.currentTarget).selectedItem;"/>

      (with public var selectedListItem:Object;)


      My List is built to load dynamicaly some SWF files

            <mx:SWFLoader id="animation"
                  source="{selectedListItem.data}"
                  autoLoad="true"
                  width="100%"/>

       

      - But now I want to display the corresponding. So I tried to contruct the String of the XML id from the selectedListItem.data:

       

      private function xmlFile(swf:String):String
               {
                  var pref:String;
              var tab=swf.split(".",2);
              tab=tab[0].split("/",2);
              pref=tab[1];
              pref=pref.split("-").join("");
              return pref;
                   }  

       

      This gives me, for example, "flexang" from "animations/flex-ang.swf". But my problem is that I want to put my XML file in my RichText area:

              <s:RichEditableText id="codeView" editable="false" textFlow="{TextFlowUtil.importFromXML(xmlFile(selectedListItem.data))}" />

       

      But xmlFile returns a String! and I do not know how to specify that it is a XML id.

       

      I hope I am clear enough.

       

      Thanks if you try to help me