<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Commenti a: AS3 &#8211; Flex: TileList with ItemRenderer scrolling problem</title>
	<atom:link href="http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/feed/" rel="self" type="application/rss+xml" />
	<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/</link>
	<description>Armisael's scientific world</description>
	<lastBuildDate>Sat, 26 Sep 2009 23:20:08 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Di: Armisael</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-49</link>
		<dc:creator>Armisael</dc:creator>
		<pubDate>Sat, 26 Sep 2009 23:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-49</guid>
		<description>It&#039;s very strange, you&#039;re right...
The code seems to be ok... I thought that the &quot;ghost&quot; problem was appearing only for custom renderers, but it seems that it&#039;s not true. Maybe it&#039;s really a bug of Flex.

I think that what it&#039;s happening is that the TileList creates only 6 tiles, calling the set data method on them using your dataProvider. When you scroll down, it calls it only for the 7th tile. Probably, because there are no other data in the dataProvider, it does not call any method on the other two tiles, leaving them as they are, with the previous image (and this is the problem). Using a custom renderer we can manage this problem, but with the default one it seems we cannot.

The fastest (and not so clean) solution I would try, is to add some dummy data with empty source at the end of the dataProvider, reaching a multiple of the tileList colCount. I don&#039;t know exactly what can be happen, but it could be that founding some data, the tileList will call the set method also on the other tiles, cleaning the image because of the empty source.</description>
		<content:encoded><![CDATA[<p>It&#8217;s very strange, you&#8217;re right&#8230;<br />
The code seems to be ok&#8230; I thought that the &#8220;ghost&#8221; problem was appearing only for custom renderers, but it seems that it&#8217;s not true. Maybe it&#8217;s really a bug of Flex.</p>
<p>I think that what it&#8217;s happening is that the TileList creates only 6 tiles, calling the set data method on them using your dataProvider. When you scroll down, it calls it only for the 7th tile. Probably, because there are no other data in the dataProvider, it does not call any method on the other two tiles, leaving them as they are, with the previous image (and this is the problem). Using a custom renderer we can manage this problem, but with the default one it seems we cannot.</p>
<p>The fastest (and not so clean) solution I would try, is to add some dummy data with empty source at the end of the dataProvider, reaching a multiple of the tileList colCount. I don&#8217;t know exactly what can be happen, but it could be that founding some data, the tileList will call the set method also on the other tiles, cleaning the image because of the empty source.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Bhootnath</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-44</link>
		<dc:creator>Bhootnath</dc:creator>
		<pubDate>Sat, 26 Sep 2009 12:21:39 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-44</guid>
		<description>it is using its default renderer.. 

&lt;pre lang=&quot;actionscript&quot;&gt;var _dp:DataProvider = new DataProvider();
var _pageNumber:Number = 0;
for (_pageNumber = 0; _pageNumber &lt; tnArray.length; _pageNumber++ )
{
var _currLabel:String = &quot;Page &quot; + String(_pageNumber + 1);
var tnPath:String = serverPath + fileServerURL + &quot;?fpath=&quot; + tnArray[_pageNumber];
_dp.addItem( { label:_currLabel, source:tnPath, commentCount: String(_commentCountSet.getItemAt(_pageNumber)) } );
}

thumbnailTileList = new TileList();						
thumbnailTileList.width = 340;// this.width - 20;
thumbnailTileList.height = 230;// this.height - 80;230=330
thumbnailTileList.scrollPolicy = ScrollPolicy.ON;
thumbnailTileList.direction = ScrollBarDirection.VERTICAL;			
thumbnailTileList.x = 10;
thumbnailTileList.y = 40;			
//thumbnailTileList.setStyle(&quot;cellRenderer&quot;, ThumbnailRenderer);
thumbnailTileList.addEventListener(ListEvent.ITEM_CLICK, thumbnailSelectedClickHandler);

thumbnailTileList.columnWidth = 102;
thumbnailTileList.rowHeight = 102;
//thumbnailTileList.columnCount = 3;
thumbnailTileList.rowCount = 2;
thumbnailTileList.x = 10;
thumbnailTileList.y = 35;
thumbnailTileList.dataProvider = _dp;&lt;/pre&gt;


The 3rd parameter in the data provider is the one for which I had to write the custom renderer but when I started getting the ghost image  problem, i commented the line where I was setting the custom cell renderer. In this example, I had 7 images to display while the visible part of Tile list was set to 3X2. When I scrolled down to the last row, all three columns had images in them, first one had real image and last two the ghost of previous row. Can you give some example on what should be done in the removing image routine.. I have tried everything, i can even get any event when i scroll down to the last row, i have tried on render, label change, and lot more but none of the events are called when i scroll down to the last row.. strangely they do get called when I scroll back up.. :S..</description>
		<content:encoded><![CDATA[<p>it is using its default renderer..</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> _dp:DataProvider = <span style="color: #000000; font-weight: bold;">new</span> DataProvider<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> _pageNumber:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>_pageNumber = <span style="color: #cc66cc;">0</span>; _pageNumber <span style="color: #66cc66;">&lt;</span> tnArray.<span style="color: #0066CC;">length</span>; _pageNumber++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> _currLabel:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Page &quot;</span> + <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_pageNumber + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> tnPath:<span style="color: #0066CC;">String</span> = serverPath + fileServerURL + <span style="color: #ff0000;">&quot;?fpath=&quot;</span> + tnArray<span style="color: #66cc66;">&#91;</span>_pageNumber<span style="color: #66cc66;">&#93;</span>;
_dp.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> label:_currLabel, source:tnPath, commentCount: <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>_commentCountSet.<span style="color: #006600;">getItemAt</span><span style="color: #66cc66;">&#40;</span>_pageNumber<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
thumbnailTileList = <span style="color: #000000; font-weight: bold;">new</span> TileList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;						
thumbnailTileList.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">340</span>;<span style="color: #808080; font-style: italic;">// this.width - 20;</span>
thumbnailTileList.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">230</span>;<span style="color: #808080; font-style: italic;">// this.height - 80;230=330</span>
thumbnailTileList.<span style="color: #006600;">scrollPolicy</span> = ScrollPolicy.<span style="color: #0066CC;">ON</span>;
thumbnailTileList.<span style="color: #006600;">direction</span> = ScrollBarDirection.<span style="color: #006600;">VERTICAL</span>;			
thumbnailTileList.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
thumbnailTileList.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">40</span>;			
<span style="color: #808080; font-style: italic;">//thumbnailTileList.setStyle(&quot;cellRenderer&quot;, ThumbnailRenderer);</span>
thumbnailTileList.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ListEvent.<span style="color: #006600;">ITEM_CLICK</span>, thumbnailSelectedClickHandler<span style="color: #66cc66;">&#41;</span>;
&nbsp;
thumbnailTileList.<span style="color: #006600;">columnWidth</span> = <span style="color: #cc66cc;">102</span>;
thumbnailTileList.<span style="color: #006600;">rowHeight</span> = <span style="color: #cc66cc;">102</span>;
<span style="color: #808080; font-style: italic;">//thumbnailTileList.columnCount = 3;</span>
thumbnailTileList.<span style="color: #006600;">rowCount</span> = <span style="color: #cc66cc;">2</span>;
thumbnailTileList.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
thumbnailTileList.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">35</span>;
thumbnailTileList.<span style="color: #006600;">dataProvider</span> = _dp;</pre></div></div>

<p>The 3rd parameter in the data provider is the one for which I had to write the custom renderer but when I started getting the ghost image  problem, i commented the line where I was setting the custom cell renderer. In this example, I had 7 images to display while the visible part of Tile list was set to 3X2. When I scrolled down to the last row, all three columns had images in them, first one had real image and last two the ghost of previous row. Can you give some example on what should be done in the removing image routine.. I have tried everything, i can even get any event when i scroll down to the last row, i have tried on render, label change, and lot more but none of the events are called when i scroll down to the last row.. strangely they do get called when I scroll back up.. :S..</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Armisael</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-36</link>
		<dc:creator>Armisael</dc:creator>
		<pubDate>Sat, 26 Sep 2009 06:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-36</guid>
		<description>I&#039;m sorry but I cannot understand. If you have commented out your custom renderer, how do you tell to the TileList to show an image? Are you saying that even if the TileList has no Renderer, it uses the last you have defined? Can you post some kind of source code?</description>
		<content:encoded><![CDATA[<p>I&#8217;m sorry but I cannot understand. If you have commented out your custom renderer, how do you tell to the TileList to show an image? Are you saying that even if the TileList has no Renderer, it uses the last you have defined? Can you post some kind of source code?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Bhootnath</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-35</link>
		<dc:creator>Bhootnath</dc:creator>
		<pubDate>Fri, 25 Sep 2009 22:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-35</guid>
		<description>hi, am also having this ghost image problem.. problem is that i even commented the custom renderer.. and still the ghost images remain.. The datasource has 7 items and i had set the tile list to 3X2 and when I scroll down, the last row where there should have been only one image, in the first box, the last two show faded images 5 and 6.. :-S.. any insight?</description>
		<content:encoded><![CDATA[<p>hi, am also having this ghost image problem.. problem is that i even commented the custom renderer.. and still the ghost images remain.. The datasource has 7 items and i had set the tile list to 3X2 and when I scroll down, the last row where there should have been only one image, in the first box, the last two show faded images 5 and 6.. :-S.. any insight?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Armisael</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-25</link>
		<dc:creator>Armisael</dc:creator>
		<pubDate>Sat, 25 Apr 2009 13:31:43 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-25</guid>
		<description>Ok, I think I could elaborate on that =)
Take this method:

&lt;pre lang=&quot;actionscript&quot;&gt;override public function set data(d:Object):void
{
  super.data = d;
  if (data != null) {
    if (data.image != null) createAndAddImage();
    // other stuff
  }
}&lt;/pre&gt;

This functions has a problem. Suppose that the first data has an image: when the TileList call the set method, the image will be added to the tile. Now, we scroll down the component. The TileList probably will reuse the tile instance, for example for the 25th data. If data[25] does not have an image, nothing happens, but the first image is still on the tile and it will appear as &quot;ghost&quot; image. So, we have to call a method to remove all the images on the tile if the data object does not contain an image:

&lt;pre lang=&quot;actionscript&quot;&gt;  
  if (_data != null) {
    if (_data.image != null) createAndAddImage();
    else removeAllImages();
    // other stuff
  }&lt;/pre&gt;

Hope it could help you!</description>
		<content:encoded><![CDATA[<p>Ok, I think I could elaborate on that =)<br />
Take this method:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#40;</span>d:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">super</span>.<span style="color: #0066CC;">data</span> = d;
  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>.<span style="color: #006600;">image</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> createAndAddImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// other stuff</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This functions has a problem. Suppose that the first data has an image: when the TileList call the set method, the image will be added to the tile. Now, we scroll down the component. The TileList probably will reuse the tile instance, for example for the 25th data. If data[25] does not have an image, nothing happens, but the first image is still on the tile and it will appear as &#8220;ghost&#8221; image. So, we have to call a method to remove all the images on the tile if the data object does not contain an image:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">  <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_data <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_data.<span style="color: #006600;">image</span> <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> createAndAddImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">else</span> removeAllImages<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #808080; font-style: italic;">// other stuff</span>
  <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Hope it could help you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Matthew Wilson</title>
		<link>http://armisael.silix.org/2009/04/as3-flex-tilelist-with-itemrenderer-scrolling-problem/comment-page-1/#comment-24</link>
		<dc:creator>Matthew Wilson</dc:creator>
		<pubDate>Sat, 25 Apr 2009 02:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://armisael.silix.org/?p=38#comment-24</guid>
		<description>I&#039;m having an issue with my TileList control...and it kinda&#039; sounds like what you describe. When I scroll vertically in my TileList, I get these &quot;ghost&quot; images that jump from one tile to the next. So an image that should be in tile 3, appears in tile 1 IN ADDITION to the images that are supposed to be in tile 1.

So it&#039;s like the itemRenderer is getting called several times for each tile, or something. Anyway, if you could elaborate on your statement above. I would love to get some more information to see if it can help me with my issue.

Great blog! Thanks for posting!</description>
		<content:encoded><![CDATA[<p>I&#8217;m having an issue with my TileList control&#8230;and it kinda&#8217; sounds like what you describe. When I scroll vertically in my TileList, I get these &#8220;ghost&#8221; images that jump from one tile to the next. So an image that should be in tile 3, appears in tile 1 IN ADDITION to the images that are supposed to be in tile 1.</p>
<p>So it&#8217;s like the itemRenderer is getting called several times for each tile, or something. Anyway, if you could elaborate on your statement above. I would love to get some more information to see if it can help me with my issue.</p>
<p>Great blog! Thanks for posting!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
