3 Replies Latest reply on Aug 17, 2012 10:15 AM by Flex harUI

    Flex 3 Item renderer in List dissapear and shifted place

    M.Kang

      I successfully added ItemRenderer in my List but whenever I scroll down to the bottom and scroll up again. The ItemRenderer in the List would be either gone or shifted places.

      I have search up on possible solution but they doesn't seen like working. I tried to put dataChange=”validateNow()” in the ItemRenderer but it doesn't work. I read something about useVirtualLayout="false" but it seen like my List doesn't have useVirtualLayout ?

      <mx:List 
             
      id="rowsList2" width="{VBoxCall.width}" height="{ scheduleViewerHeight }"
             
      rowHeight="{ scheduleViewer.rowHeight }"
             
      verticalScrollPolicy="off" verticalAlign="middle"
              
      horizontalScrollPolicy="off"
             
      alternatingItemColors="[0xEEEEEE, 0xDFDFDF]" itemRenderer="RendererState">
             
      <!-- Example to showcase Item renderer -->
             
      <mx:dataProvider>
                 
      <mx:Object label="Mr Swabby"
                            
      data="Juneau"
                            
      webPage="http://www.state.ak.us/"/>
                 
      <mx:Object label="Mrs Harrington"
                            
      data="Montgomery"
                            
      webPage="http://www.alabama.gov/" />
             
      </mx:dataProvider>
         
      </mx:List>

      Before (picture) http://i.stack.imgur.com/VxoeP.gif

      After (picture) http://i.stack.imgur.com/3qHO9.gif

      Any Ideas ?

      Regards, Mike

        • 1. Re: Flex 3 Item renderer in List dissapear and shifted place
          Flex harUI Adobe Employee

          UseVirtualLayout is for Spark List.  You issue sounds like a recycling problem.  See the item renderer posts on my blog.

           

          --

          Alex Harui

          Flex SDK Team

          Adobe Systems, Inc.

          http://blogs.adobe.com/aharui

          • 2. Re: Flex 3 Item renderer in List dissapear and shifted place
            M.Kang Level 1

            Hi Alex,

             

            I've read your blog but I still could find the solution.

            I tried to override the set data but it is not working. Whenever I scroll to the bottom and move up again, all the buttons are gone.

            Please advise me on this.

             

            Regards,

            Mike

             

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

            <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">   

                      <mx:Script>

                                <![CDATA[

                                          // Import Event and URLRequest classes.

                                          import flash.events.Event;

                                          import flash.net.URLRequest;

             

                                          override public function set data(value:Object):void{

                                                    if(value != null)

                                                    {

                                                    super.data = value;

             

                                                    if(data.label == null)

                                                    {

                                                              Button.label="";

                                                    }

                                                    else

                                                    {

                                                              if(data.label == null || data.label=="")

                                                              {

                                                                        Button.label = "";

                                                              }

                                                              else

                                                              {

                                                                        Button.label = data.label;

             

                                                              }

                                                    }

                                          }

                                                    else

                                                    {

                                                              myVBox.removeChild(Button);

                                                    }

                                          }

                                ]]>

                      </mx:Script>

             

                      <mx:VBox id="myVBox">

                                <mx:Button id="Button" width="90">

                                </mx:Button>

                      </mx:VBox>

             

            </mx:VBox>

            • 3. Re: Flex 3 Item renderer in List dissapear and shifted place
              Flex harUI Adobe Employee

              You have code that removes Button, but I don’t see any code to re-add it.  Once the Button is removed and that renderer is recycled, it will not get re-added.