Hi Manish;
Well, your suggestion *almost* works. Click on "Beta" a couple
times, and you'll see the "Alpha" row's size being increased, though
no button is added.
I could fix this by adding:
<mx:SetProperty property="height" value="60"/>
to the "openState" state declaration. I have no idea why this would
work :(
On that note: how can I better arm myself to sort out these problems
on my own? I've read the documentation on custom renderers and
states, but nothing in there would have led me to your conclusion
that the list was "shuffling" cell renderers. Is there more I can
read? Books? Sample code? Blogs?
Thanks.
--- In [email protected], Manish Jethani
<[EMAIL PROTECTED]> wrote:
>
> 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/