Thanks Tracy.

I will take your take your advice.  The result will be much cleaner than the 
quick fix approach I was trying to use - even if I could have got it working.

I am not that clear on the item renderer lifecycle (I am pretty new to flex), 
but will soon learn the specifics.


Peter Cowling


----- Original Message ----
From: Tracy Spratt <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, 18 September, 2008 19:06:40
Subject: RE: [flexcoders] Trying to refine inline itemrenderer prompt to state 
based image loading


If I am understanding correctly, I’d
say that is way too complex behavior to cram into an in-line renderer. 
Perhaps someone else will be able to give you a simple solution, but…
 
Build a full renderer class that overrides
set data() and uses invalidation with commit Properties() and 
updateDisplayList( ). 
If you are an item renderer component lifecycle expert, you can start from
scratch, otherwise, *find an example*.
 
Any data that affects the row/item-level
state you will need to store in the dataProvider, or elsewhere.  For
example, the start index of your image list.  The set data function must
cause that index value to be retreived from wherever you stored it, and then
use invalidation to ensure that the “load next 11” functionality
gets called using that index.
 
All this is necessary because renderers
are recycled.  This mean creationComplete only fires once, and anything
not set using the above data/invalidation mechanism will randomly display when
you scroll.
 
Tracy

________________________________
 
From:[EMAIL PROTECTED] ups..com [mailto: [EMAIL PROTECTED] ups.com ] On Behalf 
Of pedrocpedroc
Sent: Thursday, September 18, 2008
1:24 PM
To: [EMAIL PROTECTED] ups.com
Subject: [flexcoders] Trying to
refine inline itemrenderer prompt to state based image loading
 
Hi,

Here is the component with the inline item renderer:

<local:Component >

<local:itemRenderer >
<mx:Component> <local:imageRend
creationComplete= "outerDocument. loadFirstEleven( event.currentTar get);"
click="outerDocumen t.inView( event.currentTar get);"/>
</mx:Component>
</local:itemRendere r>

</local:Component>

Here is the creationComplete triggered function:

var count55:int= 0

public function loadFirstEleven( targetObj: Object):void{

var target:imageRend = (targetObj as imageRend);

if( count55 < Math.min(12, model.subscriptions .length ) ){

target.currentState = "loading_thumbnail" ;
count55++;
}
}

Which, as expected, changes the state in the first lot of target objects.

(Changing the state prompts imageRend to start retrieving related
images, and 'loaded' swaps out a placer image with the required one.)

So far so good, but what I really want to do is load up the first few
images, and then react to user clicks (hence the 'inView' reference)
to load up further images i.e. 13 onwards.

I have tried traversing, using the objects parent property, and then
getChildAt/getChild Index combinations, as a basis for finding the
current position + 12, but I am just guessing and its getting me nowhere.

Thanks for any help in advance.    


      

Reply via email to