Using
FlexWheel Class Directly
Sizing
the FlexWheel (Height and Width).
Let’s take the NumericWheel class as an example. Following are the steps needed to use it in applications:
<components:NumericWheel id="numericWheel" x="781" y="29" minVal="50" maxVal="200"
wheelChangeEnd="onWheelChangeEnd(event)" />
private function onWheelChangeEnd(event:WheelChangeEvent):void
{
//some wheels
have more than one column to spin in them,
//such as the AppointmentWheel.
//the event.selectedItems array holds each columns
selected
//value at the
matching index
Alert.show(event.selectedItems[0]);
}
There are 2 paths to creating your custom wheel.
Let’s continue with the NumericWheel example.
public class NumericWheel extends FlexWheel
{
…
/**override
parent to create the spin wheel with minVal..maxVal items**/
override protected function handleSpinBoxCreation():void
{
//create dp with values from min val to max val
var arr:ArrayCollection = new ArrayCollection();
for(var i:int = _minVal;i<=_maxVal;i++)
{
arr.addItem(i);
}
//addSpinBox receives a dataProvider
and an Item renderer
//in my case I wrote a simple renderer that
inherits from
//label and centers text.
//I could have used mx.components.Label as
well.
addSpinBox(arr,flexWheel.components.CenteredLabelRenderer,
_itemHeight,_itemWidth);
}
You can put the FlexWheel directly in your application and call the addSpinBox whenever you want
Important: In order for FlexWheel to work well some special consideration is to be taken when setting the height and widths.
FlexWheel visible area should fit a whole number of item renderer in height to work at its best, meaning there should be no partial visible renderers.
Set the height of the component to:
itemHeight*{num required visible items} + 2*wheelBorderThickness..
Let’s
say:
You have 10 items in your data provider = ArrayCollection([1,2,3,4,5,6,7,8,9,10])
Your renderer is a Label with (20px height)
You want to only 3 items to be visible at a time.
Your height would be 20*3 + 2*1 = 62
Partial Items: if don’t set the height as shown above you will see partial items, it will still work good and there should be no problems.
However there might be 1 or 2 items in the whole list that over them you will need 2 small drags to get them to move a whole item instead of one.
Defaults:
Since most of the FlexWheel subclasses have textual renderers the defaults are:
Height = 146
ItemHeight = 24
(ItemWidth = 24)
wheelBorderThickness = 1
Meaning 6 visible items.