1 Reply Latest reply on Sep 19, 2006 2:04 AM by flexsam

    icons in the tile List

    LifeBugs
      hello all ,

      I am trying to display images in the Tilelist component whose path is given in the xml. The xml is located on the harddrive which is loaded in my mxml application as follows :

      import flash.events.*;
      import flash.net.URLLoader;
      import flash.net.URLLoaderDataFormat;
      import flash.net.URLRequest;

      public var myXML :XML;

      var XML_URL:String = "templateList.xml"
      var myXMLURL:URLRequest = new URLRequest(XML_URL);
      var myLoader:URLLoader = new URLLoader(myXMLURL);
      myLoader.addEventListener("complete", xmlLoaded);

      function xmlLoaded(evtObj:Event):void{
      myXML = XML(myLoader.data);
      }


      I am using this myXML object as the dataProvider for tileList as follows :

      <mx:TileList id="ListOfTemplates" dataProvider="{myXML.template} " labelField="label" iconField="icon" >

      </mx:TileList>

      the strucutre of the xml templateList.xml is :

      <root>
      <template>
      <icon> sample1.jpg </icon>
      <label>sample1</label>
      </template>
      <template>
      <icon> sample1.jpg </icon>
      <label>sample2</label>
      </template>
      :
      :
      :
      </root>

      Please help me.
      Thanks in advance
        • 1. Re: icons in the tile List
          flexsam Level 1
          Your image should be embeded. Something like this...

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="getXML.send()">
          <mx:Script>
          <![CDATA[

          import mx.controls.Alert;

          [Bindable]
          [Embed(source="1_r1_c1.gif")]
          public var icon11:Class;

          [Bindable]
          [Embed(source="1_r1_c2.gif")]
          public var icon12:Class;

          [Bindable]
          [Embed(source="1_r1_c3.gif")]
          public var icon13:Class;

          ]]>
          </mx:Script>
          <mx:HTTPService id="getXML" url="LabelsNIcons.xml" showBusyCursor="true" result="myTileList.dataProvider=event.result.root.template;" fault="Alert.show('Could not get Label and Icons!!!')" />
          <mx:TileList id="myTileList" />
          </mx:Application>

          This HTTPService is getting a xml file LabelsNIcons.xml containing:
          <?xml version="1.0"?>
          <root>
          <template>
          <label>flex1</label>
          <icon>icon11</icon>
          </template>
          <template>
          <label>flex2</label>
          <icon>icon12</icon>
          </template>
          <template>
          <label>flex3</label>
          <icon>icon13</icon>
          </template>
          </root>

          Hope this helps