List with ItemRenderer becomes crazy when scrolling

Hi all

I have a list with a defined as ItemRenderer:

< mx:List id = "msgList" dataProvider = "{ca}" >
< mx:itemRenderer >
< mx:Component >
< ns1:MsgRenderer >
< / ns1:MsgRenderer >
< / mx:Component >
< / mx:itemRenderer >
< / mx:List >

inside the MsgRender component I have a very simple creationComplete function like this one which adds an icon (a yellow star or a Black Star) according to a var Boolean called Star:

private void pace (): void {}
If (this.data)
{
If {(this.data.star)
this.starIcon.source = "assets/images/ystar.png";
}
else {}
this.starIcon.source = "assets/images/bwstar.png";
}

}
}

It works very well. BUT when I scroll the list everything is messed up, the yellow star appears where it shouldn't appear etc, etc, etc.. I checked the data source "ac" with the debugger and everything is in place, it's just the icons in the list that is messed up.

No idea why this can happen, this is the first time I encounter this problem!

Greetings,

Alex

For performance reasons, the list reuses point converters when you scroll.

Point converters who paraded on top of the list are reused to

items that marched in the bottom of the list. If you expect

the data property of an element converter to change. You need to update the

State of your rendering engine when data changes. In your original

example you have been setting up rendering once to creationComplete,

rather than every time the ownership of the data changed. The usual approach

update the rendering engine when data changes is to trigger updates in the

set the rendering engine data() function, but listen to a dataChange event

will also work.

Tags: Flex

Similar Questions

  • 100% - width of list will not become crazy

    I use Flex 4.6 and works in the manufacture of some simple lists.  Each line develops only insofar as the data it contains - in other words, the bars background and separator are as wide as the data in the lines.  I've not really applied a style yet but I started a large component.  I'm going crazy with this - any advice would be MUCH appreciated.  I know I'm must be missing something obvious, but I just can't see the forest/trees/etc.  Here's what I have.

    In my HomeView, I ask the list (shown in bold below).  I show the parent containers all the way up to just under the main view where it is useful.  I'm not show all closing tags - you get the picture:

    <! - scroller - >

    < s:Scroller width = "100%" height = "100%".

    horizontalScrollPolicy = "off" >

    <!-required b/c the scrolling can handle only a single component->

    < s:Group width = '100 percent"height ="100% ">

    < s:layout >

    < s:VerticalLayout gap = "0" / >

    < / s:layout >

    <! - events - >

    < components: BBWHeaderSubComp label = "Events calendar of today" / >

    < components: BBWListComp width = '100% '.

    labelField = 'the subject '.

    itemRenderer = "views.renderer.CalendarEventRenderer"

    dataProvider = "{journal}" / >

    As you can see, is a component.  Here is the entire component:

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

    " < = xmlns:fx s:List ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    left = "0" right = "0".

    high = low '0' = '0 '.

    Width = '100% '.

    verticalScrollPolicy = "off" horizontalScrollPolicy = "off" >

    < s:layout >

    < s:VerticalLayout gap = "0" requestedMinRowCount = "1" / >

    < / s:layout >

    < fx:Declarations >

    < / fx:Declarations >

    < / s:List >

    Thanks for help.

    Try:

    Philippe

  • List control ItemRenderer question

    Hi guys I am working on a small photo Gallery. I create an xml file and try to connect to my list with itemrenderer control.

    However, when I tried to save the file, I got access of undefined property 'data' error.

    I thought we are supposed to use 'data' to refer to the current row of the data object. Here is my code... and thank you very much!

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
         
    xmlns:s="library://ns.adobe.com/flex/spark"
         
    xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
     
    <fx:Model id="pictureXML" source="data/pictures.xml"/>
     
    <s:ArrayList id="pictureArray" source="{pictureXML.picture}"/>
    </fx:Declarations>



    <s:List id="pictureGrid" dataProvider="{pictureArray}"
      
    horizontalCenter="0" top="20">
     
    <s:itemRenderer>
      
    <fx:Component>
       
    <s:HGroup>
        
    <mx:Image source="images/big/{data.source}" /> // where the error happen
        
    <s:Label text="{data.caption}"/> // where the error happen
       
    </s:HGroup>  

      
    </fx:Component>
     
    </s:itemRenderer>
    </s:List>


    </s:Application>

    My xml

    <?xml version="1.0"?>
    <album>
      
    <picture>
      
    <source>city1.jpg </source>
      
    <caption>City View 1</caption>
      
    </picture>
       
    <picture>
      
    <source>city2.jpg </source>
      
    <caption>City View 2</caption>
      
    </picture>
        
    <picture>
      
    <source>city3.jpg </source>
      
    <caption>City View 3</caption>
      
    </picture>
       
    <picture>
      
    <source>city4.jpg </source>
      
    <caption>City View 4</caption>
      
    </picture>
       
    <picture>
      
    <source>city5.jpg </source>
      
    <caption>City View 5</caption>
      
    </picture>
       
    <picture>
      
    <source>city6.jpg </source>
      
    <caption>City View 6</caption>
      
    </picture>
       
    <picture>
      
    <source>city7.jpg </source>
      
    <caption>City View 7</caption>
      
    </picture>
       
    <picture>
      
    <source>city8.jpg </source>
      
    <caption>City View 8</caption>
      
    </picture>
       
    <picture>
      
    <source>city9.jpg </source>
      
    <caption>City View 9</caption>
      
    </picture>
       
    <picture>
      
    <source>city10.jpg </source>
      
    <caption>City View 10</caption>
      
    </picture>
    </album>

    I appreciate any help!

    Although it seems strange, it apparently need a new tag after the tag :

    
    
      
        
        
      
      
        
          
            
            
              
              
            
            
          
        
      
    
    

    If this post answers your question or assistance, please mark it as such.

    Greg Lafrance - Flex 2 and 3 certified ACE

    www.ChikaraDev.com

    Training Flex and Support Services

  • Flex 4: activate the scrolling on a list with a custom itemRenderer

    I extend the component Spark list to make it look like a Halo TileList component with a counter on top. The spark list default will add a horizontal scroll bar when the list content is wider than its width. This does not happen when I use a custom itemRenderer. I don't want the always visible horizontal scroll bar. It should be automatic. I tried all day to work around the problem and I have read the documentation and tried to change most of the component properties, but I cannot yet achieve what I wanted. Here is the source code:

    Main application

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                      xmlns:s="library://ns.adobe.com/flex/spark" 
                      xmlns:mx="library://ns.adobe.com/flex/mx"
                      minWidth="955" minHeight="600" 
                      backgroundColor="#777777">
         
         <fx:Declarations>
              <fx:XML id="libraryXML" source="/assets/xml/library.xml"/>
         </fx:Declarations>
                   
         <s:List id="library" itemRenderer="CustomItemRenderer" dragEnabled="true" contentBackgroundColor="#777777" selectionColor="0x555555"
                   alternatingItemColors="[0x777777, 0x707070]">
              
              <s:dataProvider>
                   <s:XMLListCollection source="{libraryXML.children()}"/>
              </s:dataProvider>
              
              <s:layout>
                   <s:HorizontalLayout paddingLeft="0" paddingRight="0" clipAndEnableScrolling="true"/>
              </s:layout>
              
         </s:List>
    </s:Application>
    

    Custom ItemRenderer

    <?xml version="1.0" encoding="utf-8"?>
    <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:mx="library://ns.adobe.com/flex/mx" 
                        xmlns:s="library://ns.adobe.com/flex/spark" >
         
         <s:states> 
              <s:State name="normal"/> 
              <s:State name="hovered"/>
         </s:states>
         
         <s:Group id="itemsRemaining" x="90" y="5" width="20" height="20">
              <s:Ellipse  height="20" width="20">
                   <s:fill>
                        <s:SolidColor color="0x333333"/>
                   </s:fill>
              </s:Ellipse>
              
              <s:Label text="{data.length}" color="0xFFFFFF" verticalCenter="0" horizontalCenter="0" fontSize="11" fontWeight="bold"/>
         </s:Group>
         
         <mx:Image id="image" source="{data.image}" width="116" height="116" horizontalCenter="0" verticalCenter="0"/>
         <s:Label id="itemName" fontSize="14" text="{data.label}" y="95" horizontalCenter="0" color="white"/>
    
    </s:ItemRenderer>
    

    DataProvider XML

    <?xml version="1.0"?>
    <items>
         <item>
              <label>stuff 1</label>
              <image>assets/images/img1.png</image>
              <length>4</length>
         </item>
         <item>
              <label>stuff 2</label>
              <image>assets/images/img2.png</image>
              <length>9</length>
         </item>
         <item>
              <label>stuff 4</label>
              <image>assets/images/img3.png</image>
              <length>7</length>
         </item>
         <item>
              <label>stuff 5</label>
              <image>assets/images/img4.png</image>
              <length>2</length>
         </item>
         <item>
              <label>stuff 3</label>
              <image>assets/images/img5.png</image>
              <length>5</length>
         </item>
         <item>
              <label>stuff 7</label>
              <image>assets/images/img6.png</image>
              <length>8</length>
         </item>
         <item>
              <label>stuff 8</label>
              <image>assets/images/img7.png</image>
              <length>11</length>
         </item>
         <item>
              <label>stuff 9</label>
              <image>assets/images/img8.png</image>
              <length>23</length>
         </item>
         <item>
              <label>stuff 10</label>
              <image>assets/images/img9.png</image>
              <length>4</length>
         </item>
         <item>
              <label>stuff 12</label>
              <image>assets/images/img10.png</image>
              <length>2</length>
         </item>
         <item>
              <label>stuff 11</label>
              <image>assets/images/img11.png</image>
              <length>8</length>
         </item>
    </items>
    

    Here is a screenshot:

    http://img812.imageshack.us/img812/4331/screenshotir.png

    Download (84 KB) Project:

    http://www.2shared.com/file/2EpFB3K2/Flex4ListIssue.html

    I think you could fix it in 2 ways

    (1) call "invalidateDisplayList()" on the list to "updateComplete" event.

    (2) which provide the dataProvider by using binding, preInitialize event to provide the dataProvider.

    I think that data comes after the initial layout. While it will create this problem. If this is the reason why this should correct the problem.

  • Problem with list and itemRenderer

    Hallo. I need a little help. I have a list and populate this list with this code:

    var myArrayList:ArrayList = new ArrayList (myArray);

    this.myList.dataProvider = myArrayList;

    The code of my list is as follows:

    < s:List id=" lst_listaAmiciDaInvitare "width =" " 220 "height =" "x =" 15 "y =" 56 245 "skinClass =" componentiInterni.listaAmiciDaInvitare.listaAmiciPerInvito "buttonMode =" true " " > ""

    < s:layout >

    < s:VerticalLayout gap=" 2 " />

    < / s:layout >

    < s:itemRenderer >

    < fx:Component >

    < listaAmiciDaInvitare:listaAmiciItemRenderer / >

    < / fx:Component >

    < / s:itemRenderer >

    < / s:List >

    The code of my item converter is as follows:

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

    < s:ItemRenderer ' xmlns:s = ' Library://ns.Adobe.com/Flex/spark "xmlns:fx =" " http://ns.Adobe.com/MXML/2009 "

                    xmlns:d=" http://ns.Adobe.com/FXG/2008/DT "width =" " 200 "height =" 16 "autoDrawBackground =" true " " > "

    < fx:Script >

    <! [CDATA]

    protected function gruppoPrimario_clickHandler(event:MouseEvent): Sub

    {

    if ()this. chk_selezioneAmicoDaInvitare.selected)

    ce . chk_selezioneAmicoDaInvitare.selected = fake;

    else

    ce . chk_selezioneAmicoDaInvitare.selected = true;

    }

    []] >

    < / fx:Script >

    < s: states >

    < s: State " name =" normal " />

    < s: State " name =" hovered " />

    < s: State " name =" selected " />

    < / s: states >

    < s:Group click = "gruppoPrimario_clickHandler (event)" " >

    < s:CheckBox id=" chk_selezioneAmicoDaInvitare "width =" " 5 "height =" 5 "left =" 0 "red =" 0 " " / > "

                                              <s:Label id=" lbl_nomeGiocatore " x=" 15 "top =" 4 "width =" 190 "maxWidth =" 190 "maxDisplayedLines =" 1 "text =" {data.nome} "fontFamily =" Arial "fontSize =" 12 "textAlign =" left '' / > "" "" ""

    < / s:Group >

    < / s:ItemRenderer >

    Now, my list has 180 items and as you can see from the code, each element is a check box and a label. All fills properly and I see each box and the text. The problem is that when I click on a box, this box are selected but not only... The entire list on an occasional basis, he other boxes to check who is selected and I don't know why... It seems a problem of updating the lists, but I do not know... Why, if I click on a single box, 5 becomes checked?...

    Hope you can help me.

    Max

    This is because as Alex says converters are reused and as my posted code does not update the selection state of the checkbox in the datasetter, or link it it is obviously reproducible.

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

    {

    trace ("test. Data (value) ", value);

    Super.Data = value;

    CB.label = data.label;

    CB. Selected = data.selected;

    }

    Update the selected on the cb will fix the problem.

    C

  • Apple Mail only works when I restart in "safe" mode otherwise it becomes crazy, using all the capabilities of the CPU.  Seems to be linked to the case.  Any help?

    Apple Mail only works when I restart in "safe" mode otherwise it becomes crazy, using all the CPU capacity without any correct output.  Seems to be connected with caches.  Any help?

    Generally, if your Mac works correctly in Mode safe, but not normally, then you have a third-party software that runs at the start of the origin of the problem.

    Safe mode disables most of the extensions of third-party startup and some Apple hardware, so it could be another problem for Apple, but I have never heard of your problem.

  • a macbook pro with retina display becomes hot when in use?

    A macbook pro with retina display becomes hot when in use?

    Yes.  All of the skin of the MBP is part of the evacuation of heat, not only the arriere-charniere event.  That's why running the MBP on a hard flat surface is better, so the room air can cool down all surfaces.  He put on a hidden or your knees when running may block exposure to air.

    High intensity running video uses graphics and CPU harder, needing cooling.

  • Drop-down lists lists loop until the first position when scrolling down

    Original title : Drop-down lists keep scrolling to the first position

    As soon as there is a drop involved or any time there is more than a list of what can be seen on the screen, something is causing the list to scroll to the first position.  It also happens on anything that uses a mouse to move a bar on the side, using keyboard does not help, she returned at the beginning.  Please, someone let me know how to solve this problem, I can't get anything done as much of what I do has lists in drop-down lists.

    Thanks for your help

    BlueFairy2012

    Hello

    1. the problem occurs with any particular application or all applications?
    2. don't you make changes to the computer before the show?
    3. what operating system is installed on the computer?

    I suggest you perform the clean boot and check if the problem persists.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: Follow step 7 clean boot KB929135 article to reset the computer in normal mode.

    Additional information:
    The problems with the mouse button or scroll the parameters
    http://support.Microsoft.com/kb/303091

  • How do with java: bar navigation remains visible and pops up when scrolling to the bottom of the page

    Hello


    I want as my default-navigation bar to jump to the top of the page when scrolling down the site - it must remain visible as on this page: www.yourpagemaker.de

    It's a German Site.

    Can someone help me with this? Where do I have to insert Java Script and how can I give this command?

    Thank you

    ELISA.

    You must change your nav to have a. affix the class with JavaScript (not Java).

    Bootstrap model 3 - attach nav after the scrolling example code

    Nancy O.

  • Problems with the passage of the anchor when scrolling down

    Hello! I got problems with my lag anchors to the left when scrolling down. I tried all the solutions found in some other Adobe Forums, but none seems not to work with mine

    Here is my website

    Home

    I hope someone can help!

    That was the problem with me. Using the 100% width option, he showed me my background and text blocks are indeed too wide. Thank you!

  • Photoshop: image becomes black when you try to select with inclusive

    image becomes black when you try to select with inclusive

    (edited)

    Powering the OpenGL in the Performance preference and restarting Photoshop have no bearing on the question?

  • Fuzzy letters on websites when scrolling in Firefox 19 (with either smooth scrolling active / disabled)

    Hello

    Recently, I updated to Firefox 19, and since I had some problems when scrolling on Web sites: some lines/letters fade.
    I did some research online and found a trick to disable smooth scrolling, so I only have restarted Firefox, but the issue is still not resolved.
    I have not had this problem until the recent upgrade.
    Is this a known issue? Is there a solution to this?
    If no, how are we going to go back to the previous version of Firefox, I can only find the download links to the latest version...

    Thank you
    Lars

    Hello Santuzzo, try turning off hardware acceleration and check again.

    Thank you

  • When selecting a "select list with redirect', all variables are losing value

    I have a form where a field (: P38_CUSTOMER_ID) receives its value from the parent report and it appears as: "display text (saves the State)).".

    I have 2 fields from selection list. The first (: P38_COUNTRY) is shown in the form "select list with redirect.
    As soon as I select the value (name of the country) in this list box, I lose the value: P38_CUSTOMER_ID.

    An idea on what I need to do to ' P38_CUSTOMER_ID to avoid losing its value?

    Thanks in advance.

    You are welcome. There are many options to choose from ;-)

    Be sure to note the answers as people only get points if you do.

    Thank you
    Dimitri

  • The list with the variable row height

    Hi, please look at the example below

    What I do is:

    -J' I create an item in list with variableRowHeight set to true.

    -The dataProvider contains 2 numbers: 2 and 3

    -In the itemRenderer, this causes in progress of creation, respectively 2 and 3 buttons

    -As you can see, the height of the list is badly calculated, a scroll bar appears.

    -When you switch 2 and 3 (so that the table becomes 3 and 2), the list is too large.

    -I could make a custom list class and override the method of measurement, but I can't understand what to measure. I should be able to walk through the itemRenderers and measure their height.

    Any ideas?

    THX,

    Dany

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="vertical"creationComplete =" init () "> "

    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;

    [Bindable]
    private var dp:ArrayCollection;

    private function init (): void
    {
    var a: Array = [2, 3];
    DP = new ArrayCollection (a);
    }

    []] >
    < / mx:Script >
    < mx:List width = "100%" dataProvider = variableRowHeight "{dp}" = "true" rowCount = "{dp.length}" >
    < mx:itemRenderer >
    < mx:Component >
    < mx:VBox >
    < mx:Script >
    <! [CDATA]
    Import mx.controls.Button;
    override public function set data(value:Object):void
    {
    Super.Data = value;

    If (this.numChildren == 0)
    {
    for (var i: int = 0; i < value; i ++)
    {
    var b:Button = new Button();
    b.label = "Row" + value;
    this.addChild (b);
    }
    }
    }
    []] >
    < / mx:Script >
    < / mx:VBox >
    < / mx:Component >
    < / mx:itemRenderer >
    < / mx:List >
    < / mx:Application >

    Sorry, it's a method on a list called measureHeightOfItems.  The results,

    Add viewMetrics.top and down and you should have the exact size of the

    List.

  • The list with many images

    Hello!

    I have a list with a lot of images in the itemRenderer, over 500.

    I use virtualization on this list.

    When people scroll quickly down, it can take a bit to load images.

    Issues related to the:

    1. in what order the list control to load images? Up and down the entire list or Topp down only the visible part?

    2. is there anyway I can give priority to a certain image to load first on others? The images have the source property set to a relative path on the server.

    3. is there anything I can do to speed up the process of loading in general?

    Thank you!

    The list does not load images, because of your item converter.  I suppose you load these images by substituting the data setter method in the rendering engine.

    When the list of the first loads it creates just enough converters to show what is in view (due to virtualization), let the top 10 items.  This means that the first 10 images will be loaded, but no other images will be loaded unless you scroll the list to expose new items.  If you want to have some images available before others so you can have your application load them if its not busy and in this way, they could be available before the user scrolls.

    Even if you were to load all images before creating the list you might seem still some flickering when scrolling because what are they are recharged in as user autour scrolls.  To remedy this, you might want to consider caching the images as they are loaded, there is an example here: http://flexponential.com/2010/01/10/caching-images-loaded-from-a-spark-item-renderer/

Maybe you are looking for

  • Allergy Apple Watch sport - protective film

    My wife Gets a skin irritation while wearing the Apple Watch Sport. So I'm looking for a protective sheet to the back of the Apple Watch. I have haven´t found such a tool. Can anyone give me a tip?

  • Can Equium A100 - I use E drive for data backup?

    My Equium A100-27 has a 80 GB hard drive, it is split in the C drive half and drive E. I understand that the E drive is used for system recovery purposes, but can I also use it to store data? If I use it for how much room must be left free for system

  • Help me please with this code

    Hello It is the first program that I tried to write alone... and I'm stuck. I am trying to acquire data from a scope. I want the vi to load only the first field of application preparation time, the code is executed. Once the installation has been loa

  • Cannot use my CD or dvd burner

    I use windows 7 Professional 64-bit And receive a message with shutter automatic windows update DtSoft Virtual CdRom Device with errors as well as Hl-DT-ST DVD +-RW GH50N ATA Device Windows cannot verify the digital signature for the drivers required

  • activate functionalty edition as a company on a standard edition

    HelloI would like to know if it is possible to activate a feature of Enterprise edition (materialized views) on a standard.I know that you can switch between versions, from standard to the enterprise by an upgrade, but I need just a feature of busine