7 Replies Latest reply on Sep 15, 2010 1:33 AM by anilreddy_narra

    display the image in flex using XML content???

    anilreddy_narra Level 1

      Can u find the belox XML and flex code..

      Can any one help to display the image in flex using XML content?

       

      Flex code:

       

      <mx:Repeater

       

       

      id="rp" width="950">

      <mx:VBox

       

      backgroundColor="#6B735B" label="{rp.currentItem.body_frag_title}" >

       

      <mx:Label

       

       

      id="lblid" text="{rp.currentItem.body_frag_title}" color="#070000" fontSize="15"/>

      <mx:Text

       

      text="{rp.currentItem.body_frag_text}" width="950" color="#070000" fontSize="10"/>

      <mx:Image

       

       

      source="{rp.currentItem}"/>

      </mx:VBox>

      </mx:Repeater>

       

      XML code

       

      <

       

      body_frag>

      <

       

      body_frag_title>Persistent Objects

      </

       

      body_frag_title>

      <

       

      pic src="Images/2.jpg"></pic>

      <

       

      body_frag_text>

      Data in database systems are held in persistent objects

      A persistent object survives the processes that creates and manipulates it

      When such a process ceases to exist the persistent object remains

       

       

      </

       

      body_frag_text>

       

       

      </

       

      body_frag>

      ~

       

       

       

        • 1. Re: display the image in flex using XML content???
          BhaskerChari Level 4

          Hi anilreddy_narra,

           

          Try the code below....

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

          <mx:XML id="myXml" xmlns="">
          <body_frag>
            <body_frag_title>Persistent Objects</body_frag_title>
            <pic src="Images/2.jpg"></pic>
            <body_frag_text>
            Data in database systems are held in persistent objects
            A persistent object survives the processes that creates and manipulates it
            When such a process ceases to exist the persistent object remains
            </body_frag_text>
          </body_frag>

          </mx:XML>
          <mx:Repeater id="rp" width="950" dataProvider="{myXml}">
            <mx:VBox backgroundColor="#6B735B" label="{rp.currentItem.body_frag_title}" >
             <mx:Label id="lblid" text="{rp.currentItem.body_frag_title}" color="#070000" fontSize="15"/>
             <mx:Text text="{rp.currentItem.body_frag_text}" width="950" color="#070000" fontSize="10"/>
             <mx:Image source="{rp.currentItem.pic.@src}"/>
            </mx:VBox>
          </mx:Repeater>

          </mx:Application>

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          1 person found this helpful
          • 2. Re: display the image in flex using XML content???
            anilreddy_narra Level 1

            Hello,

            How did u take the below code? body_frag, body_frag_title, body_frag_text are located in XML file that is my data source. Flex is my presentation side. I didn't understand .......... <mx:XML id="myXml" xmlns="">.

            my question is: how to load the XML image in flex? I have 3layers in my project. Data source is XML,Business layer is c# webservice and presentation layer is flex. I have displayed the label and text from XML. But,I am facing the problem with image..

            Can u please help me?

             

            <mx:XML id="myXml" xmlns="">
            <body_frag>
              <body_frag_title>Persistent Objects</body_frag_title>
              <pic src="Images/2.jpg"></pic>
              <body_frag_text>
              Data in database systems are held in persistent objects
              A persistent object survives the processes that creates and manipulates it
              When such a process ceases to exist the persistent object remains
              </body_frag_text>
            </body_frag>

            </mx:XML>

            • 3. Re: display the image in flex using XML content???
              BhaskerChari Level 4

              Hi anilreddy_narra,

               

              I have just used your xml which you have posted in your previous post and placed in a local xml tag so that I can have access to your xml.

               

              You dont worru about that you just replace the Repeater below with your repeater component and check whether image is being displayed now ..??

               

              Make sure that the images are present in your Images folder in your Flex application...

               

              <mx:Repeater id="rp" width="950" dataProvider="{myXml}">
                <mx:VBox backgroundColor="#6B735B" label="{rp.currentItem.body_frag_title}" >
                 <mx:Label id="lblid" text="{rp.currentItem.body_frag_title}" color="#070000" fontSize="15"/>
                 <mx:Text text="{rp.currentItem.body_frag_text}" width="950" color="#070000" fontSize="10"/>
                 <mx:Image source="{rp.currentItem.pic.@src}"/>
                </mx:VBox>
              </mx:Repeater>

               

               

               

              Thanks,

              Bhasker

              1 person found this helpful
              • 4. Re: display the image in flex using XML content???
                anilreddy_narra Level 1

                XML file is different..Where can I use xml id=myXml?

                 

                The below is my flex code..I have 2images in src/Images/1.jpg,2.jpg..

                What is the data provider to my repeater in this case?

                 

                Flex code:

                 

                <mx:VBox

                 

                 

                 

                label="Theory" borderColor="#030704">

                <mx:Label

                 

                text="Theory" id="lblTheory" fontSize="30" textDecoration="underline" fontFamily="Times New Roman" color="#ED4307"/>

                <mx:LinkBar

                 

                 

                dataProvider="{viewStack1}" direction="horizontal"

                height="

                29" textDecoration="underline"/>

                <mx:ViewStack

                 

                id="viewStack1" height="600" width="800">

                <mx:Repeater

                 

                 

                id="rp" width="950">

                <mx:VBox

                 

                backgroundColor="#6B735B" label="{rp.currentItem.body_frag_title}" showEffect="{wipeRight}" hideEffect="{wipeLeft}">

                <mx:Label

                 

                 

                id="lblid" text="{rp.currentItem.body_frag_title}" color="#070000" fontSize="15"/>

                <mx:Text

                 

                text="{rp.currentItem.body_frag_text}" width="950" color="#070000" fontSize="10"/>

                <mx:Image

                 

                 

                source="{rp.currentItem.pic.@src}"/>

                </mx:VBox>

                </

                 

                mx:Repeater>

                </mx:ViewStack>

                </mx:VBox>

                 

                I have one big XML file..THe below is the smallest part among tha part....

                 

                XML code part:

                <

                 

                body_frag>

                <

                 

                body_frag_title>Persistent Objects

                </

                 

                body_frag_title>

                <

                 

                pic src="Images/2.jpg"></pic>

                <

                 

                body_frag_text>

                Data in database systems are held in persistent objects

                A persistent object survives the processes that creates and manipulates it

                When such a process ceases to exist the persistent object remains

                 

                 

                </

                 

                body_frag_text>

                 

                 

                </

                 

                body_frag>

                <

                 

                body_frag>

                <

                 

                body_frag_title>Relations

                </

                 

                body_frag_title>

                <

                 

                pic src="Images/1.jpg"></pic>

                 

                <

                 

                body_frag_text>Persistent objects in a relational database exist as Relations

                Relations can be thought of as tables if the tables possess certain properties

                Normalisation is the process of creating tables that have the properties of relations, and no redundant data

                </

                 

                body_frag_text>

                </

                 

                body_frag>

                 

                 

                Webservice code:

                public

                 

                string getTheory(string workBookName,string workPageName)

                {

                 

                XmlDocument xDoc = new XmlDocument();

                xDoc.Load(Server.MapPath(

                "modules_workbooks.xml"));

                 

                 

                 

                 

                XmlNode workBook = xDoc.SelectSingleNode(@"//workbooks/workbook[module_title=" + @"""" + (string)workBookName + @"""" + "]");

                 

                XmlNodeList workPageNode = workBook.ChildNodes;

                 

                StringBuilder str = new StringBuilder();

                 

                foreach (XmlNode nx in workPageNode)

                {

                 

                if (nx.Name == "workpage")

                {

                 

                if (nx.Attributes["pagetitle"].Value == workPageName)

                {

                 

                 

                try

                {

                 

                foreach (XmlNode n in nx)

                {

                 

                if (n.Name == "theory")

                {

                str.Append(

                "<NewDataSet>");

                str.Append(n.InnerXml.ToString());

                str.Append(

                "</NewDataSet>");

                }

                }

                }

                 

                catch (Exception ex)

                {

                 

                throw (ex);

                }

                 

                }

                }

                }

                 

                 

                return str.ToString();

                 

                }

                 

                • 5. Re: display the image in flex using XML content???
                  anilreddy_narra Level 1

                  I am using web services to get the data from XML..

                   

                  <mx:WebService

                  id="

                   

                  businessCatalystWebService"

                  wsdl="

                  http://localhost:57980/WebService1/Service.asmx?wsdl"

                  showBusyCursor="

                  true">

                   

                   

                   

                   

                  <mx:operation name="getMenu" resultFormat="object" result="handleMenu(event)"/>

                   

                   

                   

                  <mx:operation name="getTheory" resultFormat="object" result="handleResult1(event)"/>

                   

                   

                   

                   

                  <mx:operation name="getObjectives" resultFormat="object" result="handleResult2(event)"/>

                   

                   

                   

                   

                  <mx:operation name="getPractices" resultFormat="object" result="handleResult3(event)"/>

                   

                   

                   

                   

                  <mx:operation name="getLinks" resultFormat="object" result="handleResult4(event)"/>

                   

                   

                   

                   

                  <mx:operation name="getAssessments" resultFormat="object" result="handleResult5(event)"/>

                   

                   

                   

                   

                  <mx:operation name="getModuleGuide" resultFormat="object" result="handleResult6(event)"/>

                   

                   

                   

                   

                  </mx:WebService>

                   

                  The below is the handlefunction for getTheory

                   

                  <?xml version="1.0" encoding="utf-8"?>

                  <mx:Application

                   

                  xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"

                  height="

                  100%" layout="absolute"

                  creationComplete="inIt()" viewSourceURL="

                  srcview/index.html"

                  backgroundImage="

                  C:\Users\h8069566\Documents\Flex Builder 3\XmlReading\src\wallpaper_1280x1024.jpg" backgroundColor="#97A5E3">

                   

                  [

                  Bindable]

                   

                  public var menuBarCollection:XMLListCollection;

                   

                  public

                   

                  function inIt():void

                  {

                  businessCatalystWebService.getMenu();

                   

                   

                  }

                   

                   

                   

                  private function complete():void

                  {

                  pnl.visible =

                  true;

                  rp.dataProvider =

                  "";

                  rp2.dataProvider =

                  "";

                  rp3.dataProvider =

                  "";

                  rp4.dataProvider =

                  "";

                  rp5.dataProvider =

                  "";

                  rp6.dataProvider =

                  "";

                  lblMod.visible =

                  false;

                  lblAssess.visible =

                  false;

                  lblObj.visible =

                  false;

                  lblLinks.visible =

                  false;

                  lblPra.visible =

                  false;

                  lblTheory.visible =

                  false;

                  businessCatalystWebService.getTheory(menuItm,itemText);

                  businessCatalystWebService.getObjectives(menuItm,itemText);

                  businessCatalystWebService.getPractices(menuItm,itemText);

                  businessCatalystWebService.getLinks(menuItm,itemText);

                  businessCatalystWebService.getAssessments(menuItm,itemText);

                  businessCatalystWebService.getModuleGuide(menuItm,itemText);

                  }

                   

                   

                   

                  public

                   

                   

                  function handleResult1(event:ResultEvent):

                  void

                  {

                   

                   

                  var queryxml:XML = new XML(event.result);

                   

                  var xl:XMLListCollection = new XMLListCollection(queryxml.body_frag);

                   

                   

                  if(xl.length > 0)

                  {

                  rp.dataProvider = xl;

                  lblTheory.visible =

                  true;

                  }

                   

                   

                  }

                   

                  I hope u understand the problem..please help me....

                   

                  Thank you

                   

                  • 6. Re: display the image in flex using XML content???
                    BhaskerChari Level 4

                    Hi anil,

                     

                    You dont need to use the xml id that I have used (myXml) ....You just give the same dataprovider which you are assigning earliar to  your Repeater component.

                     

                    But just replace only the Repeater component code which I have posted but give your own dataprovider which you are assigning earliar instead of myXml as I have used in my code...

                     

                    Thanks,

                    Bhasker

                    • 7. Re: display the image in flex using XML content???
                      anilreddy_narra Level 1

                      I tried the code which u have sent.

                      <mx:Image source="{rp.currentItem.pic.@src}"/>..

                      Image is not displaying with the above code..I think some problem with loading..I didn't understand what was the problem....