2 Replies Latest reply on Nov 18, 2010 9:58 AM by alinator11

    how to get updated data automatically  on flex scroll screen


      i am showing invoices and corresponding articles in the invoice on flex scrolling screen.details of invoices i am storing in a xml object through java class. i want that whenever i create a invoice it should automatically appear on screen.what method i should implement to get new created invoices on scrolling screen.

      code for strucrute



      private function converToCollection( inData:XML ):ArrayCollection



      var tempArrCollection:ArrayCollection = new ArrayCollection([]);


      for(var i=0; i<inData.INVOICE.length(); i++)


      var objToAdd:Object = new Object();

      objToAdd.ID = inData.INVOICE[i].ID;

      objToAdd.NAME = inData.INVOICE[i].NAME;

      //added by Mitesh on 12-11

      objToAdd.DATE = inData.INVOICE[i].DATE;

      objToAdd.STATUS = inData.INVOICE[i].STATUS;

      objToAdd.LOCK = inData.INVOICE[i].LOCKED;

      objToAdd.LOCK_COLOR = inData.INVOICE[i].LOCKCOLOR;

      objToAdd.EXISTANCE = inData.INVOICE[i].EXISTANCE ;

      objToAdd.ARTICLES = null;


      if( inData.INVOICE[i].ARTICLE.length() )



      var articleArrColl:ArrayCollection = new ArrayCollection([]);

      var articleLen:uint = inData.INVOICE[i].ARTICLE.length();


      for( var k = 0; k<articleLen;k++)


      articleArrColl.addItem({DESC:inData.INVOICE[i].ARTICLE[k].DESC,CODE:inData.INVOICE[i].ARTI CLE[k].CODE, QUANTITY:inData.INVOICE[i].ARTICLE[k].QTY});


      objToAdd.ARTICLES = articleArrColl;




      tempArrCollection.addItem( objToAdd );





      return tempArrCollection;





      display part of invoices


      <mx:Canvas id="articlesContainer" x="15" y="38" width="90%" />

      <mx:HBox horizontalScrollPolicy="off" verticalScrollPolicy="off">

      <mx:Button id="closeBtn"  styleName="closeButtonStyle" x="15" />

      <mx:Label  text="{xmlObj.ID}" id="invoiceId"  width="120" fontSize="15" color="#373EA1" fontWeight="bold" textAlign="right" fontFamily="ArialEmbedded"/>

      <mx:Label  text="{xmlObj.NAME+'(total articles - '+ArrayCollection(xmlObj.ARTICLES).length+' )'}" width="350" color="#1B1D6D" fontWeight="bold" fontSize="15" textAlign="left" fontFamily="ArialEmbedded"/>

      <mx:Label  text="{xmlObj.DATE}" id="invoiceDate"  width="300" fontSize="15" color="#373EA1" fontWeight="bold" textAlign="left" fontFamily="ArialEmbedded"/>

      <mx:Spacer width="100%" />

      <mx:Button id="printBtn" styleName="printButtonStyle"/>


      <mx:VBox id="printInvoiceBlock" width="100%" backgroundColor="#FFFFFF" visible="false">

      <mx:HBox horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundColor="#FFFFFF">

      <mx:Label  text="{xmlObj.ID}" id="printInvoiceId"  fontSize="8" color="#000000" fontWeight="bold" textAlign="right" fontFamily="Arial"/>

      <mx:Label  text="{xmlObj.NAME+'( total articles - '+ArrayCollection(xmlObj.ARTICLES).length+' )' }" color="#000000" fontWeight="bold" fontSize="7" textAlign="left" fontFamily="Arial"/>


      <mx:VBox id="printArticlesContainer" width="100%" backgroundColor="#FFFFFF"/>




      <!--<mx:Image id="paidImg" visible="true" x="30" y="38" width="30" source="@Embed(source='assets/skins.swf', symbol='paid')" height="14"/>-->


        • 1. Re: how to get updated data automatically  on flex scroll screen
          alinator11 Level 2

          When you create your scroller, give it an ID (if you create it in MXML). If you create the scroller in

          AS, make sure that whatever MXLM component you want to add it to has an ID. And, I would also try to use Sparks containers whenever possible. In any event, after you have defined your Scroller, this will make it simple.


          1. Create a DataGroup.

          2. Set DataGroup.dataSource = An ArrayList that contains all your screens.

          3. Set Scroller.viewPort = dataSource

          4. Create a new method to add new invoices to the ArrayList that contains all your screens.


          Below is truncated code from where I do this same thing... I create the scroller in AS and use it with MXML components.


              public class FeedConfigVideoScroller
                   * This is our actual list data.
                   * **/
                  private var vidRendList:ArrayList = new ArrayList();
                  // a variable to tell us to update or not.
                  private var selectionChanged:Boolean = false;
                  // a variable to hold ids of videos we're keeping
                  private var ids:ArrayList;
                  // an array list of items to be removed from this list.
                  //before the item is added to the map, its label will be updated
                  //and check box deselected.
                  private var deselectedList:ArrayList = new ArrayList();
                  private var addedScreens:Boolean = false;
                  private var d:DataGroup;
                  private var scroller:Scroller;
                  private var feedID:int;
                  public function FeedConfigVideoScroller(){
                      d = new DataGroup();
                      d.dataProvider = vidRendList;
                      var vert:VerticalLayout = new VerticalLayout();
                      vert.horizontalAlign = "left";
                      d.layout = vert;
                      d.width = 340;   
                      d.height = 370;
                      scroller = new Scroller();
                      scroller.height = 370;
                  public function getScroller():Scroller {
                      scroller.viewport = d;
                      return scroller;
                  public function addFCVLayoutComp(vidLayout:FeedConfigVidLayout):void {
                  public function setVidRendList(vidRendList:ArrayList):void {
                      this.vidRendList = vidRendList;       

          • 2. Re: how to get updated data automatically  on flex scroll screen
            alinator11 Level 2

            BTW, you may notice that I'm adding custom components to the scroller. I create all my screens through recursion (when I have a lot of them to add). This allows me to use renderers to make my screens where I may have a screen that has an image, a text area and a checkbox. All of those items are one screen to be added to the scroller. Hence the FCVLayoutComp Objects in my sample code provided.