2 Replies Latest reply on Dec 16, 2009 2:15 PM by maheekp

    components xml data

    maheekp

      Hi guys,

       

      I have an application as below. I have a component and main application.

      I am connecting to an xml file through the component and calling the component in main application.

       

      Let me know what is wrong in my code.

       

      component ---

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="testData.send()">

      <mx:Script>
        <![CDATA[
         import mx.rpc.events.ResultEvent;
         import mx.collections.XMLListCollection;
        
         [Bindable]
         private var _headerData : XML = new XML();
        
         private function set headerData(evt:ResultEvent):void{
        
         _headerData = new XML(evt.result.testData);
        
         }
        ]]>
      </mx:Script>

           <mx:HTTPService id="testData" url="/xml/test.xml" />

        <mx:HBox width="100%">
        <mx:Spacer width="10" />
        <mx:Grid id="headerGrid" width="100%" height="77"
              borderStyle="solid" borderColor="#03131E" verticalGap="1" horizontalGap="25"
              >
         <mx:GridRow>
          <mx:GridItem>
           <mx:Label text="Name: "/>
          </mx:GridItem>
          <mx:GridItem>
           <mx:Label text="{XML(_headerData.NAME)}" fontWeight="bold"/>
          </mx:GridItem>
          <mx:GridItem>
           <mx:Label text="Role: "/>
          </mx:GridItem>
          <mx:GridItem>
           <mx:Label text="{XML(_headerData.ROLE)}" fontWeight="bold"/>
          </mx:GridItem>
          <mx:GridItem>
           <mx:Label text="Type: "/>
          </mx:GridItem>
          <mx:GridItem>
           <mx:Label text="{XML(_headerData.TYPE)}" fontWeight="bold"/>
          </mx:GridItem>           
         </mx:GridRow>
                  
        </mx:Grid>
      </mx:HBox>
      </mx:HBox>

       

       

       

      main application ---
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
      layout="absolute" xmlns:components="components.*"
      >

      <mx:Panel id="onepanel"
           height="100%"
           width="100%"
           title="Title"
           textAlign="center"
           color="green" x="0" y="0"
           layout="vertical">
          
      <components:HeaderSection width="100%"/>


      xml file --- name is test.xml--- placed under src/xml/test.xml

      <?xml version="1.0"?>
      <APP>

      <HEADER>

      <NAME>ABC Name</NAME>
      <ROLE>Doctor</ROLE>
      <TYPE>Neuro</TYPE>

      </HEADER>
      </APP>