Re: [flexcoders] ClassFactory, properties, itemrenderers and changing prop dynamically

2011-09-22 Thread Alex Harui
If it were me, I would subclass the List and add an “associatedList” property 
that references this map.

The logic for setting itemEnabled in the renderer is hopefully in an override 
of commitProperties.  I would override the data setter to call 
invalidateProperties.

Then in commitProperties, you can do something like:

{code}
var list:MyList = owner as MyList;
if (list) // will be null in the destination list since it is just a List 
and not a MyList
{
var map:Object = list.associatedList;
{code}

On 9/22/11 12:39 PM, "grimmwerks"  wrote:






I see your point -- I'm already doing an object / hashmap of items; what would 
be the best way of having the itemrenderer's check said list though?  I'm 
actually working with PureMVC and all code is in the mediator, everything in 
the view - ie list and of course itemrenderers... so it's not even something 
that an itemrenderer would be privy to...  plus if I'm using the same 
itemrenderer for the source and the drop list I'd almost have to tell  
hmmm;  could I *pass* the list each itemrenderer watches through the factory 
properties.?



On Sep 22, 2011, at 3:18 PM, Alex Harui wrote:



Because renderers get recycled, it is not recommended to access a renderer 
instance and change properties on it.  There is a indexToItemRenderer() method, 
but I wouldn’t use it for this.

The recommended practice is an “associated list”, essentially a weak-reference 
dictionary or object map that stores additional information associated with the 
data objects (not the renderers).  In this case, I would probably use a 
dictionary and stuff each dropped object in the dictionary.  Each renderer will 
compare its data property to see if it is in the dictionary and set the 
itemEnabled accordingly.


On 9/22/11 11:33 AM, "grimmwerks"  wrote:






Here's another convoluted question -- I've got a list that is bound to an array 
of a certain Class - let's cal them Permissions.  In the Permissions class 
you've got userId, read and write (booleans there, id for userId, normal stuff).

I'm using the same itemrenderer in two lists - a source list which is not 
editable and a drop list which is;  the itemrenderer has an 'editable' variable 
and I'm setting each list's ClassFactory to this same itemrenderer, with one 
ClassFactory's properties setting editable to false, one to true.  All that is 
good.

Now the strange request I JUST had from someone here is that once an item is 
dragged and dropped from the source list to the drop list, the item in the 
source list should dim to show that it's already been chosen, unable to choose 
again.   I've created a property called itemEnabled in the itemrenderer,! 
defaulting to true (so it's ignored in the droplist basically).

Here's the thing; it would be simple enough to set a particular item's 
'itemenabled' property in the dataproviider and it would trickle down; but 
since this is a list of cast objects that don't have the itemEnabled property 
it's a no go...

So is there a way of selecting an itemrenderer or item at a certain position in 
the sourcelist and setting IT's itemEnabled to false? Is it something with the 
classfactory for a specific item?


Garry Schafer
grimmwerks
gr...@grimmwerks.com
portfolio: www.grimmwerks.com/   











--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui


Re: [flexcoders] ClassFactory, properties, itemrenderers and changing prop dynamically

2011-09-22 Thread grimmwerks
I see your point -- I'm already doing an object / hashmap of items; what would 
be the best way of having the itemrenderer's check said list though?  I'm 
actually working with PureMVC and all code is in the mediator, everything in 
the view - ie list and of course itemrenderers... so it's not even something 
that an itemrenderer would be privy to...  plus if I'm using the same 
itemrenderer for the source and the drop list I'd almost have to tell  
hmmm;  could I *pass* the list each itemrenderer watches through the factory 
properties.?



On Sep 22, 2011, at 3:18 PM, Alex Harui wrote:

> 
> 
> Because renderers get recycled, it is not recommended to access a renderer 
> instance and change properties on it.  There is a indexToItemRenderer() 
> method, but I wouldn’t use it for this.
> 
> The recommended practice is an “associated list”, essentially a 
> weak-reference dictionary or object map that stores additional information 
> associated with the data objects (not the renderers).  In this case, I would 
> probably use a dictionary and stuff each dropped object in the dictionary.  
> Each renderer will compare its data property to see if it is in the 
> dictionary and set the itemEnabled accordingly.
> 
> 
> On 9/22/11 11:33 AM, "grimmwerks"  wrote:
> 
>> 
>>  
>>  
>>
>> 
>> Here's another convoluted question -- I've got a list that is bound to an 
>> array of a certain Class - let's cal them Permissions.  In the Permissions 
>> class you've got userId, read and write (booleans there, id for userId, 
>> normal stuff).
>> 
>> I'm using the same itemrenderer in two lists - a source list which is not 
>> editable and a drop list which is;  the itemrenderer has an 'editable' 
>> variable and I'm setting each list's ClassFactory to this same itemrenderer, 
>> with one ClassFactory's properties setting editable to false, one to true.  
>> All that is good.
>> 
>> Now the strange request I JUST had from someone here is that once an item is 
>> dragged and dropped from the source list to the drop list, the item in the 
>> source list should dim to show that it's already been chosen, unable to 
>> choose again.   I've created a property called itemEnabled in the 
>> itemrenderer,! defaulting to true (so it's ignored in the droplist 
>> basically).
>> 
>> Here's the thing; it would be simple enough to set a particular item's 
>> 'itemenabled' property in the dataproviider and it would trickle down; but 
>> since this is a list of cast objects that don't have the itemEnabled 
>> property it's a no go...
>> 
>> So is there a way of selecting an itemrenderer or item at a certain position 
>> in the sourcelist and setting IT's itemEnabled to false? Is it something 
>> with the classfactory for a specific item?
>> 
>> 
>> Garry Schafer
>> grimmwerks
>> gr...@grimmwerks.com
>> portfolio: www.grimmwerks.com/  
>> 
>> 
>> 
>> 
>> 
>>  
>>
>> 
>> 
> 
> -- 
> Alex Harui
> Flex SDK Team
> Adobe System, Inc.
> http://blogs.adobe.com/aharui
> 
> 
> 

Garry Schafer
grimmwerks
gr...@grimmwerks.com
portfolio: www.grimmwerks.com/







Re: [flexcoders] ClassFactory, properties, itemrenderers and changing prop dynamically

2011-09-22 Thread Alex Harui
Because renderers get recycled, it is not recommended to access a renderer 
instance and change properties on it.  There is a indexToItemRenderer() method, 
but I wouldn’t use it for this.

The recommended practice is an “associated list”, essentially a weak-reference 
dictionary or object map that stores additional information associated with the 
data objects (not the renderers).  In this case, I would probably use a 
dictionary and stuff each dropped object in the dictionary.  Each renderer will 
compare its data property to see if it is in the dictionary and set the 
itemEnabled accordingly.


On 9/22/11 11:33 AM, "grimmwerks"  wrote:






Here's another convoluted question -- I've got a list that is bound to an array 
of a certain Class - let's cal them Permissions.  In the Permissions class 
you've got userId, read and write (booleans there, id for userId, normal stuff).

I'm using the same itemrenderer in two lists - a source list which is not 
editable and a drop list which is;  the itemrenderer has an 'editable' variable 
and I'm setting each list's ClassFactory to this same itemrenderer, with one 
ClassFactory's properties setting editable to false, one to true.  All that is 
good.

Now the strange request I JUST had from someone here is that once an item is 
dragged and dropped from the source list to the drop list, the item in the 
source list should dim to show that it's already been chosen, unable to choose 
again.   I've created a property called itemEnabled in the itemrenderer,! 
defaulting to true (so it's ignored in the droplist basically).

Here's the thing; it would be simple enough to set a particular item's 
'itemenabled' property in the dataproviider and it would trickle down; but 
since this is a list of cast objects that don't have the itemEnabled property 
it's a no go...

So is there a way of selecting an itemrenderer or item at a certain position in 
the sourcelist and setting IT's itemEnabled to false? Is it something with the 
classfactory for a specific item?


Garry Schafer
grimmwerks
gr...@grimmwerks.com
portfolio: www.grimmwerks.com/ 










--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui