06-18-2011 05:24 PM
06-19-2011 12:11 AM
FYI - PickerLists do not suffer from the same problem.
Reworked sample code below.
package
{
import flash.display.Sprite;
import flash.events.Event;
import qnx.ui.data.DataProvider;
import qnx.ui.picker.Picker;
import qnx.ui.picker.PickerList;
import qnx.ui.tween.Scroller;
[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
public class SliderSample extends Sprite
{
private const scrollWidth:Number = 250;
private const scrollHeight:Number = 45;
private const monthWidthRatio:Number = 2.1;
private const dayWidthRatio:Number = 1;
private const yearWidthRatio:Number = 1.6;
private var arrDay:Array;
private var arrMonth:Array;
private var arrYear:Array;
//private var arrDPs:Array;
private var dpDay:DataProvider;
private var dpMonth:DataProvider;
private var dpYear:DataProvider;
private var dayPicker:PickerList;
private var monthPicker:PickerList;
private var yearPicker:PickerList;
public function SliderSample()
{
//stage.nativeWindow.visible = true;
arrDay = new Array();
arrMonth = new Array();
arrYear = new Array();
dayPicker = new PickerList();
monthPicker = new PickerList();
yearPicker = new PickerList();
/* Setup the years */
for (var i:int=1; i<=2050; i++){
arrYear.push ({label: i});
}
dpYear = new DataProvider(arrYear);
yearPicker.dataProvider = dpYear;
/* Setup the months January - December */
arrMonth.push({label: "January"});
arrMonth.push({label: "February"});
arrMonth.push({label: "March"});
arrMonth.push({label: "April"});
arrMonth.push({label: "May"});
arrMonth.push({label: "June"});
arrMonth.push({label: "July"});
arrMonth.push({label: "August"});
arrMonth.push({label: "September"});
arrMonth.push({label: "October"});
arrMonth.push({label: "November"});
arrMonth.push({label: "December"});
dpMonth = new DataProvider(arrMonth);
monthPicker.dataProvider = dpMonth;
/* Setup the days */
arrDay = new Array();
for (i = 1; i<= 31; i++){
arrDay.push({label: i, data:i});
}
dpDay = new DataProvider(arrDay);
dayPicker.dataProvider = dpDay;
/* Setup the size and width ratios of
* the picker and its columns
*/
dayPicker.width = scrollWidth*(dayWidthRatio/(monthWidthRatio+dayWid thRatio+yearWidthRatio));
dayPicker.height = scrollHeight;
monthPicker.width = scrollWidth*(monthWidthRatio/(monthWidthRatio+dayW idthRatio+yearWidthRatio));
monthPicker.height = scrollHeight;
monthPicker.x = dayPicker.x + dayPicker.width;
yearPicker.width = scrollWidth*(yearWidthRatio/(monthWidthRatio+dayWi dthRatio+yearWidthRatio));
yearPicker.height = scrollHeight;
yearPicker.x = monthPicker.x + monthPicker.width;
/* Try to set the date to JUNE 19, 2011 */
/* Note:Indices are 0-indexed */
dayPicker.selectedIndex = 18;
monthPicker.selectedIndex = 5;
yearPicker.selectedIndex = 2010;
addChild(dayPicker);
addChild(monthPicker);
addChild(yearPicker);
}
}
}
06-19-2011 10:39 AM
Note, PickerList seems to have its own problem. Once populated, the height of the pickerList returns a massive value (i.e. yearPicker.height = 2162), even though on screen it looks fine. The problem arises when you add the picker on top of a scrollPane. Now the scrollPane thinks it's scrollContent is huge and creates a long scroll.
06-21-2011 10:21 PM
06-23-2011 08:55 PM
This bug was fixed in the 1.1 SDK. Give it a try if you haven't already.