I use flex SDK 4.5.1 and use spark component DropDownList.
I want to dynamically change the dropDown width(not the button of the dropdownList, just the dropdown itself, which is opened when the button is clicked) to a fixed size (let's say - 140).
I managed to do so by coding this:
<s:DropDownList
id="cSelector"
prompt=...
dataProvider=...
labelFunction="{ getOpLabel }"
open="{adjustWidth()}"
changing=...
/>
However, the dropdown isn't resized immediately after clicking on the dropDownList - I can see the resize process for a half of a second. Can this be fixed or implemented differently? How?
In general, I prefer that the dropdown size will be adjusted by the widest item in the list, but this doesn't happen and it seems too complicated to fix it.
Note: The coding should be made in mxml file only.
Thanks in advance
edit:
I also tried to do the following:
<s:DropDownList
id="cSelector"
prompt=...
dataProvider=...
labelFunction="{ getOpLabel }"
creationComplete="{handleOpenEvent()}"
changing=...
/>
Then added:
protected function handleOpenEvent():void
{
cSelector.addEventListener(DropDownEvent.OPEN, changeWidth);
}
protected function changeWidth(evt:Event):void
{
cSelector.dropDown.width = 135;
}
But I still see the fast animation every time I open the dropdown. The first time is the longest one.