4 Replies Latest reply on Jul 23, 2009 10:23 PM by flx23

    list item renderer problem :(

    flx23

      I have a list further having an itemrenderer..i am displaying images in the item renderer following is the item renderer design code:-

       

       

      <mx:Canvas alpha="0.8" autoLayout="false"  borderStyle="none"  top="0"  left="0" bottom="0" horizontalScrollPolicy="off" verticalScrollPolicy="off"  xmlns:mx="http://www.adobe.com/2006/mxml" width="383" textAlign="left">

       

      <mx:Image id="TopImage" toolTip='{data.DrawerName}' id="tests" source="@Embed(source='../../Assets/drawer_img.png')" width="383"  x="0"   height="75"/>  
      <mx:Label id="lblDrawerName" fontWeight="bold" paddingLeft="18" textAlign="left" fontSize="11" width="166" text='{data.DrawerName}' x="80" y="5" />
      <mx:Image id="LastImage" source="@Embed(source='Assets/arrow.png')" maintainAspectRatio="true" x="349" y="26"  click="getstatus()"  />

       

       

       

      </mx:Canvas>    

       

      now as i click the "last image" i am replacing the image source of the top image. i have a drawerimage which on viewing list displays closed drawer and if i click the last image then replace the top image source with the openimage source..it replace quite well..but problem comes if the scroll the items after that..then the open image of drawer randomly changes the item position,..like if i click the first..then if i scroll it moves to 8th if further then 7 and so on...can any one clear the picture to me ..exactly whats going wrong...or i am missing smthing...please help

        • 1. Re: list item renderer problem :(
          ShardulSingh Level 3

          Pls add this code inside your ItemRenderer.

           

           

           

          <mx:Script>
          <![CDATA[
          override public function set data(value:Object):void
          {
              super.data = value;
          }

          ]]>
          </mx:Script>

           

           

           

          It will resolve your problem.

           

           

           

          With Regards,

           

          Shardul Singh Bartwal

          1 person found this helpful
          • 2. Re: list item renderer problem :(
            flx23 Level 1

            can you explain me a lil that what exactly this code is doing..

            i have placed the code in the item renderer and on the main component where i have the list control i am changing the image on o item click of list

             

             

            //    -------------------------           item click function

             

            [Embed(source="Assets/drawer_img.png")]
                            public var imgdrw:Class;

             

            [Embed(source="Assets/open_drawer6.png")]
                            public var imgopen:Class;

             

            private function onContactClick(evt:ListEvent):void
                        {

                                 var item:DrawerRenderer=DrawerRenderer(evt.itemRenderer);
                                    if(item.ViewDrawerFolderStatus==true)
                                    {   
                                          item.lblDrawerName.x=105;
                                        item.lblDrawerName.y=28;
                                         item.tests.source=imgopen;
                                        item.tests.width=383;
                                        item.tests.height=91;
                                        item.tests.x=0;
                                        item.height=91;
                                   }

            }

             

            item renderer componet code:--

             

            private  function getstatus():void
                       {
                           ViewDrawerFolderStatus=true;
                       }
                       override public function set data(value:Object):void
                    {
                     super.data = value;
                    }

             

            <mx:Canvas alpha="0.8" autoLayout="false"  borderStyle="none"  top="0"  left="0" bottom="0" horizontalScrollPolicy="off" verticalScrollPolicy="off"  xmlns:mx="http://www.adobe.com/2006/mxml" width="383" textAlign="left">

             

             

             

            <mx:Image toolTip='{data.DrawerName}' id="tests" source="@Embed(source='../../Assets/drawer_img.png')" width="383"  x="0"   height="75"/>  
            <mx:Label id="lblDrawerName" fontWeight="bold" paddingLeft="18" textAlign="left" fontSize="11" width="166" text='{data.DrawerName}' x="80" y="5" />
            <mx:Image source="@Embed(source='Assets/arrow.png')" maintainAspectRatio="true" x="349" y="26"  click="getstatus()"  />

             

             

             

            </mx:Canvas>        

             

             

             

             

            here is what i am doin but still i m not close to the result

             

            what i am missing

            • 3. Re: list item renderer problem :(
              ShardulSingh Level 3

              Hi,

               

              Can u tell me wht is your requirement so that I can give something similar to you.

              Please tell me in detail.What you want to do on the click of the items in the List?

               

               

               

              Shardul Singh Bartwal

              1 person found this helpful
              • 4. Re: list item renderer problem :(
                flx23 Level 1

                Well shardul thanks a lot for your code..

                 

                the override method solved my problem that i was having with the items in item render

                 

                Explanation:-

                 

                as in code

                 

                in item renderer i have three controls namely label and two image control...   one image was of a closed drawer and other for an icon..or u can say a kind of button

                 

                i was replacing image source of the drawer image with an open drawer image ,on the click of that icon...now as i click the icon,drawer image changes, but problem was if i scroll then the image source of some other drawer image gets replaced i.e. the source once changed of an item didnt remain stable..for that particular image..now as i applied your code..it solved this problem of at a time one image source to be changed of one particular item ,even on scroll..

                 

                 

                thanks,,