4 Replies Latest reply on Apr 4, 2007 3:46 PM by justinc9112

    Simple name showing as [object Object]

    justinc9112
      This is my app everything runs fine and there are no errors except when the data list on the right of movie names doesn't display names, but instead [object Object]. Did I mix something up in my code below, cause it works, except that the names arn't generated as mentioned.


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" horizontalAlign="center" verticalAlign="center" viewSourceURL="srcview/index.html">

      <mx:Panel title="Movie Releases" layout="horizontal" width="802" height="498">

      <mx:List id="movies" dataProvider="{mmovie}" labelField="movie" selectedIndex="0" width="178"/>

      <mx:VBox horizontalAlign="center" width="100%" height="100%">

      <mx:Image id="picture" right="0" source="{mmovie.getItemAt(movies.selectedIndex).image}"/>

      <mx:Form id="details" width="100%" height="303">

      <mx:FormItem label="Name:" width="100%" height="23">
      <mx:TextInput id="nameInput" text="{mmovie.getItemAt(movies.selectedIndex).name}" width="471"/>
      </mx:FormItem>

      <mx:FormItem label="Genre:" width="100%">
      <mx:TextInput id="genreInput" text="{mmovie.getItemAt(movies.selectedIndex).genre}" width="470"/>
      </mx:FormItem>

      <mx:FormItem label="Cast:" width="100%" height="51">
      <mx:TextArea id="castInput" text="{mmovie.getItemAt(movies.selectedIndex).cast}" height="49" width="471"/>
      </mx:FormItem>

      <mx:FormItem label="Description:" width="100%" height="103">
      <mx:TextArea id="descInput" text="{mmovie.getItemAt(movies.selectedIndex).description}" width="472" height="101"/>
      </mx:FormItem>

      <mx:Button visible="false" label="Save Changes" click="this.saveChanges();" enabled="false"/>
      </mx:Form>
      </mx:VBox>

      </mx:Panel>

      <mx:ArrayCollection id="mmovie">

      <mx:Object>
      <mx:image>images/bobby.jpg</mx:image>
      <mx:name>Bobby</mx:name>
      <mx:genre>Drama</mx:genre>
      <mx:cast>Anthony Hopkins, Sharon Stone, Martin Sheen, Demi Moore, Christian Slater, Helen Hunt, William H. Macy</mx:cast>
      <mx:description>The lives of 22 individuals are changed forever when they converge on the Ambassador Hotel for Robert F. Kennedy's primary election night party; a party in which the up-and-coming political heavyweight was gunned down. Set against the backdrop of cultural issues including racism and class differences, these guests are at the hotel for different reasons and sections of America and end up coming together to mourn one of the great political tragedies of the mid-20th Century.</mx:description>
      </mx:Object>

      <mx:Object>
      <mx:image>images/relative-strangers.jpg</mx:image>
      <mx:name>Relative Strangers</mx:name>
      <mx:genre>Comedy</mx:genre>
      <mx:cast>Ron Livingston, Kathy Bates, Neve Campbell, Danny DeVito, Beverly D'Angelo, Ed Begley Jr., Star Jones</mx:cast>
      <mx:description>Dr. Richard Clayton is a man on the fast track to success with a beautiful fiancee, a successful career and a new book climbing the best seller list. But when his brother tells him he is adopted, he learns that his REAL parents are crude, rude and downright unbearable. With his life in shambles and his family in disarray, he realizes that you can't choose your parents, but you can certainly learn a lot from them.</mx:description>
      </mx:Object>



      </mx:ArrayCollection>

      <mx:Script>
      <![CDATA[
      private function saveChanges():void
      {
      var updatedMov:Object = this.mmovie.getItemAt(this.movies.selectedIndex);
      updatedMov.name = this.nameInput.text;
      updatedMov.genre = this.genreInput.text;
      updatedMov.cast = this.castInput.text;
      updatedMov.description = this.descInput.text;
      this.mmovie.setItemAt(updatedMov, this.movies.selectedIndex);
      this.mmovie.refresh();
      }
      ]]>
      </mx:Script>

      <mx:Style>
      Panel
      {
      borderStyle: solid;
      headerColors: #e7e7e7, #d9d9d9;
      backgroundAlpha: 100;
      paddingTop: 10;
      }

      List
      {
      paddingLeft: 10;
      paddingRight: 10;
      paddingTop: 10;
      paddingBottom: 10;
      }
      </mx:Style>

      </mx:Application>