To make itemRenderer states work correctly during scrolling, you must
update a dataProvider item property to record that state on user action,
then in the set data() function, ( or in the "updateDisplayList()"
function) you must read this state property and set the item renderer
state accordingly.

 

List-based controls re-use the same visual elements when you scroll,
they just change the data.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of gdoucen
Sent: Tuesday, January 02, 2007 12:20 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] expandable itemRenderer with state inside a list

 

Hi,

Here is my problem.

I want to make a list with items that expand/collapse when they are
clicked. Everything works until the scrollbar appears.
If i have 5 items.
i click the first that expands. i scroll the list to the last item
that was hidden to see that it is expanded !!! when i scroll up to the
first item, it is collapsed !!!!! And the seconds items seems to be
connected with the fourth...Hope, i am clear.

Here is the code:

<mx:List id="dialturns"
width="450"
height="200"
variableRowHeight="true"
dataProvider="{dp}"
itemRenderer="DialTurnRenderer"
/>

the renderer is

<mx:Canvas 
xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
currentState="{activeState}">
<mx:Script>
<![CDATA[

import flash.events.Event;

[Bindable]
public var question:String;

[Bindable]
public var response:String;

[Bindable]
public var activeState:String="";


override public function set data( value:Object ):void
{

super.data = value;

this.question = value.question;
this.response = value.response;
}

private function switchDisplay( event:Event ):void
{
activeState = ( activeState == "expandedState" ) ? "" :
"expandedState";
} 
]]>
</mx:Script>

<mx:LinkButton x="0" y="0" label="{question}"
click="switchDisplay(event)" />

<mx:states>
<mx:State name="expandedState">
<mx:AddChild>
<mx:Text x="0" y="24" id="txtResponse" text="{response}" />
</mx:AddChild>
<mx:SetProperty name="height" value="120" />
</mx:State>
</mx:states>

</mx:Canvas>

The code is very common...the result less.

Have u got an idea? Feel free to redirect me.

Thanks in advance

 

Reply via email to