On 2/10/06, tobiaspatton <[EMAIL PROTECTED]> wrote:
> I think I sorted out why you are not seeing the problem. In the file
> ItemRenderer.mxml, the top-level component tag (mx:VBox) has
> the "height" attribute set. Remove this attribute and run the
> application.

Okay, this works:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
xmlns="*" layout="absolute">
       <mx:ArrayCollection id="ac">
               <mx:Array>
                       <mx:Object label="Alpha" />
                       <mx:Object label="Beta" />
               </mx:Array>
       </mx:ArrayCollection>

       <mx:VBox id="vb" width="300">
               <mx:List labelField="label"
                                variableRowHeight="true"
                       rowHeight="60"
                       dataProvider="{ac}"
                       width="300">
                <mx:listItemRenderer>
                        <mx:Component>
<mx:VBox xmlns:mx="http://www.macromedia.com/2005/mxml"; xmlns="*"
click="DoItemClick(event)"
       currentState="{dataObject.state}">
       <mx:Script>
               <![CDATA[
                       public function DoItemClick(
event:MouseEvent ):void
                       {
                               dataObject.state = ( currentState ==
null ) ? "openState" : null;
                                                                // trigger 
binding
                                                                dataObject = 
dataObject;
                       }
               ]]>
       </mx:Script>

       <mx:states>
               <mx:State name="openState">
                       <mx:AddChild>
                               <mx:Button label="{dataObject.label}"/>

                       </mx:AddChild>
               </mx:State>
       </mx:states>

       <mx:Label text="{dataObject.label}"/>

</mx:VBox>
                        </mx:Component>
                </mx:listItemRenderer>
               </mx:List>
       </mx:VBox>
</mx:Application>

I'm using an inline renderer, but you can remove it outside (it was
just for my convenience).

So basically what was happening is that the List was reshuffling the
cell renderer objects after the click - so the object you clicked on
ended up in a new position.  My solution is to save the state in the
data provider instead and have it bound to the "currentState"
property.  Check it out.


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to