2 Replies Latest reply on Feb 7, 2010 10:15 AM by e2dev

    HTTPService exercise error question

    learnflex1

      Friends,

      I am following the exercise to pull data using HTTPService from a XML file. When I run the following code I get the error "catalogData variable not defined". I am not able to find the issue with the code.

       

      Please help/advise

      Thanks

      -------------------------------

       

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

      <mx:Application

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="catalogService.send()">

       

       

       

       

       

      <mx:Script>

      <![CDATA[

       

       

      import mx.collections.ArrayCollection;

       

      import mx.rpc.events.ResultEvent;

       

      [BINDABLE]

       

      private var catalogData:ArrayCollection;

       

       

      private function resultHandler(event:ResultEvent):void {

      catalogData=event.result.catalog.book;

      };

       

       

      ]]>

      </mx:Script>

       

      <mx:HTTPService

       

      id="catalogService"

      url="

      catalog.xml"

      result="resultHandler(event)"

      />

       

      <mx:DataGrid

       

      dataProvider="(catalogData)"

      width="

      80%" height="100%"/>

       

      </mx:Application>

        • 1. Re: HTTPService exercise error question
          learnflex1 Level 1

          Wanted to add the xml file as well for your reference

           

          <?xml version="1.0"?>

          <catalog>

          <book>

          <author>Gambardella, Matthew</author>

          <title>XML Developer's Guide</title>

          <genre>Computer</genre>

          <price>44.95</price>

          <publish_date>2000-10-01</publish_date>

          <description>An in-depth look at creating applications

          with XML.</description>

          </book>

          <book>

          <author>Ralls, Kim</author>

          <title>Midnight Rain</title>

          <genre>Fantasy</genre>

          <price>5.95</price>

          <publish_date>2000-12-16</publish_date>

          <description>A former architect battles corporate zombies,

          an evil sorceress, and her own childhood to become queen

          of the world.</description>

          </book>

          <book>

          <author>Corets, Eva</author>

          <title>Maeve Ascendant</title>

          <genre>Fantasy</genre>

          <price>5.95</price>

          <publish_date>2000-11-17</publish_date>

          <description>After the collapse of a nanotechnology

          society in England, the young survivors lay the

          foundation for a new society.</description>

          </book>

          </catalog>

          • 2. Re: HTTPService exercise error question
            e2dev Level 2

            You have parentheses () around the word catalogData in your DataGrid dataProvider property. Use curly braces {} instead for bindings. HTHs.