I have created a custom control Which contains an header(HBox) and list control below the header. I can open and close the list (Meaning list.height = 0 and list.height = 200) by using the header click event. Initially the list will be in closed state (height = 0). When we open it for the first time. It takes too much time. For the successive open of the same list looks smoother ( I suppose this is because itemrenderer is being reused). I want to open the list for the first time smoothly. Any one please help
开发者_高级运维I have created my own renderer for list control which contains one 5 combobox inside a HBox
It does sound like you are recreating a drop down list, but the reason it takes too long to load your list the first time is because it has created no item renderers. A list control only creates as many item renderers as fits within it at any given time. Because you start with height = 0 no item renderers are created, so changing the height the first time forces the creation and validation of all the item renderers.
To fix this, make your list create and maintain its item renderers when it is created.
Create the list and leave its height at 200 but set its visibility to false. Even with false visibility the list is still created, validated, and maintainted on the display list. Add your effects for showing and hiding the list as the showEffect and hideEffect styles of the list then simply toggle visible with your header click.
Just using Button as a drop-in item renderer for something other than a simple label.
<mx:VBox verticalGap="0">
<mx:HBox click="list.visible = !list.visible">
<s:Label text="click me"/>
</mx:HBox>
<mx:List id="list" height="200" visible="false" labelField="label">
<mx:dataProvider>
<s:ArrayCollection>
<fx:Object label='Button 1' />
<fx:Object label='Button 2' />
<fx:Object label='Button 3' />
<fx:Object label='Button 4' />
<fx:Object label='Button 5' />
<fx:Object label='Button 6' />
</s:ArrayCollection>
</mx:dataProvider>
<mx:itemRenderer>
<fx:Component>
<mx:Button />
</fx:Component>
</mx:itemRenderer>
<mx:showEffect>
<s:Fade alphaFrom="0" alphaTo="1" duration="1500"/>
</mx:showEffect>
<mx:hideEffect>
<mx:Fade alphaFrom="1" alphaTo="0" duration="1500" />
</mx:hideEffect>
</mx:List>
</mx:VBox>
精彩评论