views:

47

answers:

2

I need a for loop which would print from year 2000 to 2099.

[Bindable]
private var yearValue:Array 

private function we():void {
    var i:Number;
    for(i=2000;i<=2099;i++){
        yearValue = new Array(i);

    }
}

 <mx:ComboBox id='year' labelField="Year" dataProvider="{yearValue}">           
            </mx:ComboBox>

When i populate in my combox box it does not load.

+2  A: 

Should look something like this

private function we():void {
    var i:int;
    yearValue = new Array();                      
    for(i=2000;i<=2099;i++){
         yearValue.push(i);
    }
}
Virusescu
+3  A: 

The problem is that you are overwriting the array in each iteration of your for loop. It should look like this instead:

var i:Number;
yearValue = new Array();
for(i=2000;i<=2099;i++) {
    yearValue.push(i);
}
pgb