1 Reply Latest reply on Oct 27, 2007 4:15 AM by Gregory Lafrance

    RepeaterDemo.mxml run locally

    mrjimmy410
      I am having trouble running some of the Flex 2.0 Samples locally. In the Flex 2.0 Samples Explorer( http://flexapps.macromedia.com/flex2beta3/explorer/explorer.html) the RepeaterDemo.mxml runs fine but when I copy the code into my FlexBuilder IDE I am running into two issues.

      First it seems like the ArrayCollection needs a ArrayUtils.ToArray()...
      Second it can not find the name element in the product xml.

      What is the difference between the sample code for the Flex 2.0 Samples Explorer and running it in eclipse?

      Sample Code

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

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" backgroundAlpha="0"
      creationComplete="srv.send()">

      <mx:Script>

      import mx.collections.ArrayCollection;

      [Bindable]
      public var catalog:ArrayCollection;

      </mx:Script>


      <mx:HTTPService id="srv" url=". http://flexapps.macromedia.com/flex2beta3/explorer/assets/catalog.xml" useProxy="false"
      result="catalog = new ArrayCollection(srv.lastResult.catalog.product)"/>

      <mx:Tile>
      <mx:Repeater id="list" dataProvider="{catalog}">
      <mx:VBox>
      <mx:Label text="{list.currentItem.name}"/>
      </mx:VBox>
      </mx:Repeater>
      </mx:Tile>

      </mx:Application>
        • 1. Re: RepeaterDemo.mxml run locally
          Gregory Lafrance Level 6
          The following code seems to work. Although I was not getting exactly the errors you were getting, I was getting errors. My key change was using result="catalog = srv.lastResult.catalog.product as ArrayCollection instead of result="catalog = new ArrayCollection(srv.lastResult.catalog.product)"/>

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" backgroundAlpha="0" creationComplete="srv.send()">
          <mx:Script>
          import mx.collections.ArrayCollection;

          [Bindable]
          public var catalog:ArrayCollection = new ArrayCollection();
          </mx:Script>

          <mx:HTTPService id="srv" url=" http://flexapps.macromedia.com/flex2beta3/explorer/assets/catalog.xml" useProxy="false"
          result="catalog = srv.lastResult.catalog.product as ArrayCollection"/>

          <mx:Tile>
          <mx:Repeater id="list" dataProvider="{catalog}">
          <mx:VBox>
          <mx:Label text="{list.currentItem.name}"/>
          </mx:VBox>
          </mx:Repeater>
          </mx:Tile>
          </mx:Application>