Some additional information...
It's only happening with the first item. I discovered it after reading this... http://stackoverflow.com/questions/645323/how-do-i-stop-a-datagrids-first-row-itemrenderer -from-instantiating-adding-initi/788015. But I still don't know how to keep this from happening.
1 person found this helpful
Could I ask why it's important to know if it triggers twice?
I'm sure Alex Harui will have a good answer for this.
1 person found this helpful
When is the dataProvider set?
If I had to theorize, the TileList gets created w/ a null dataProvider; this creates a single itemRenderer, all good.
Then you retrieve a dataProvider from a remote service which changes the dataProvider from null to non-null.
This forces the itemRenderers to re-create; causing what appears to be a second trace.
Run through this in debug mode and look at the memory space on the itemRenderer. I bet it changed for whatever reason.
Thanks for the reply! You bring up a good point. There is really no practical reason for me to need to figure this out except that I'm wondering if I have some fundamental misunderstanding about how itemrenderers work.
How I came across this was I was instantiating a timer in the creationComplete handler so that I could animate something in the itemrenderer (a progress bar just for testing purposes). This gliche seemed to result in two timers running at once. If this wasn't just for testing, I probably could have used the ENTER_FRAME event and been just fine.
You're probably right though... probably not worth obsessing about though I'm still curious. Thanks for your help!
Thanks for your reply! The data provider was set some time after the instantiation of the TileList. However, if I simply do the following (and never set the dataProvider programatically) I continue to have the same problem:
I'm not sure if this disproves your theory but I'm fairly new to flex and I don't know how to look at the memory space for the itemRenderer.
Anyway, I do appreciate the suggestion.
I've ruled out all of my extraneous code as the source of the problem. The very simplest of implementations seems to exhibit this behavior. Take the following:
------ ItemRendererTest.mxml -----
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:TileList id="_tileList" itemRenderer="CustomItemRenderer">
<mx:Object label="First Item" />
<mx:Object label="Second Item" />
------ CustomItemRenderer.mxml -------
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
public function onCreationComplete():void
trace("Creation Complete: " + data.label);
That's all the code and it prints the "First Item" twice. This is looking a lot like a bug to me
The TileList may make a hidden renderer used for measuring to determine the tile sizes. Since renderers can be recycled, assuming the number of events you'll get is probably not a good idea.
Flex SDK Developer
Adobe Systems Inc.
Thanks for the reply! That makes perfect sense. I will definitely take your advice not assume that only one event fires.