2 Replies Latest reply on Feb 8, 2007 9:24 PM by Cheree Singal

    List Control and Array Collections

      Please excuse me as I am quite the newbie at this but I will tell you what I am trying to do.

      First I have an XML file called Jobs.xml which contains the following:

      <?xml version="1.0" encoding="utf-8"?>
      <State stateName="New York">
      <City cityName="Syracuse">
      <careerTitle>Speech Language Pathologist - SYR</careerTitle>
      <careerTitle>Occupational Therapist - SYR</careerTitle>
      <City cityName="Buffalo">
      <careerTitle>Speech Language Pathologist - BUF</careerTitle>
      <careerTitle>Occupational Therapist - BUF</careerTitle>
      <State stateName="Florida">
      <City cityName="Miami">
      <careerTitle>Speech Language Pathologist - MIA</careerTitle>
      <careerTitle>Occupational Therapist - MIA</careerTitle>

      In a component off of my main app I need to populate a list control with the careerTitle information based on what State and City was previously choosen. Both of these are referenced by 2 variables stateRef and cityRef.

      The following is what I have now to populate the list control, all I can get it to do is list out {object object} twice.

      In the script block I have this

      private var careersCol:ArrayCollection;
      private function careersDataHandler(event:ResultEvent):void {
      careersCol = event.result.JOBS.JOB.State;

      Then I have this

      <mx:HTTPService id="careers" url="XML/Jobs.xml" result="careersDataHandler(event)"/>
      <mx:List x="10" y="35" width="416" height="87" fontSize="12" fontFamily="Verdana" dataProvider="{careersCol}" labelField="{careersCol}"></mx:List>

      If you can point me in any direction I would greatly appreciate it.
        • 1. Re: List Control and Array Collections
          theLoggerGuy Level 1
          I can help you a bit :-)

          to add the information to your list you need provide an id for your list (I've used "myList") and also add something like the following to your "CareersDataHandler" function:

          myList.dataProvider.addItem( careersCol[ 0 ].stateName );

          However, you will still have your [Object] [Object] items. Sorry, but I can't figure that one out. I tried event.preventDefault(); at the end of your function, but to no avail. Please publish your answer when you get one.

          • 2. Re: List Control and Array Collections
            Cheree Singal Level 1
            I dont know if it makes sense... Plz try labelField="careersCol" coz as far as I know, labelField has to be a string, specifying the name of the property that needs to be displayed in the list.