Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to display products list from an xml file in adobe flex
    primarykey
    data
    text
    <p>I have an html file with the following code as a list of products</p> <pre><code>&lt;productstore&gt; &lt;product id='A1'&gt; &lt;image lbl="Apple" src="assets/apple.png" /&gt; &lt;price&gt;$11.00&lt;/price&gt; &lt;description&gt;Keeps doctor away&lt;/description&gt; &lt;code&gt;ap01&lt;/code&gt; &lt;/product&gt; &lt;/productstore&gt; </code></pre> <p>I want to display the image with the name and price in a canvas (Flex with flash builder 4.5).I followed the example given in the link <a href="http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/" rel="nofollow">http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/</a></p> <pre><code>&lt;mx:XML id="xml" source="prod.xml" /&gt; &lt;mx:XMLListCollection id="xmlListColl" source="{xml.image}" /&gt; &lt;mx:TileList id="tileList" x="492" y="10" width="255" height="316" columnCount="2" columnWidth="125" dataProvider="{xmlListColl}" itemRenderer="TileListItemRenderer" rowCount="4" rowHeight="100" verticalScrollPolicy="on"/&gt; </code></pre> <p>Also the modification I am looking at is to add dragAccept rather than a click event unlike the example. </p> <p>This is my TileListItemRenderer</p> <pre><code>&lt;mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" x="492" y="10" width="255" height="316" horizontalAlign="center" verticalAlign="middle"&gt; &lt;mx:Image source="{data.@src}" /&gt; &lt;mx:Label text="{data.@lbl}" /&gt; &lt;/mx:VBox&gt; </code></pre> <p>When I build and run the list is empty, not sure what am I missing. Any help would be appreciated. </p> <p>I now modified the code trying to implement the following link and again stuck: <a href="http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/" rel="nofollow">http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/</a></p> <p>main.mxml</p> <pre><code> private function init():void { var srcUrl:String = FlexGlobals.topLevelApplication.application.parameters.srcUrl; if(srcUrl) { ViewSource.addMenuItem(this, srcUrl); } loadProducts('prod.xml'); } private function loadProducts(src:String):void { httpService.url = src; httpService.send(); } private function httpService_result(evt:ResultEvent):void { var xmlList:XMLList = XML(evt.result).product.image; xmlListColl = new XMLListCollection(xmlList); } </code></pre> <p>Itemrenderer </p> <pre><code>&lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" x="492" y="10" width="255" height="316" &gt; &lt;mx:Image source="{data.image}" /&gt; &lt;mx:Label text="{data.name}" /&gt; &lt;/mx:Canvas&gt; </code></pre> <p>xml</p> <pre><code>&lt;productlist&gt; &lt;product&gt; &lt;name&gt;Apple&lt;/name&gt; &lt;image&gt;assets/apple.png&lt;/image&gt; &lt;price&gt;$11.00&lt;/price&gt; &lt;description&gt;Keeps doctor away&lt;/description&gt; &lt;code&gt;ap01&lt;/code&gt; &lt;/product&gt; &lt;/productstore&gt; </code></pre> <p>Still no luck....</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload