PDA

View Full Version : Create Repeater in ActionScript


angie
05-22-2008, 12:39 PM
Does anybody know how to create a Repeater in ActionScript rather than MXML? I am using the following code but I can't seem to get the child descriptors to work. Thanks.


var a:Array = new Array();
a.push({label:"A", data:"a"});
a.push({label:"B", data:"b"});
a.push({label:"C", data:"c"});

var rep2:Repeater = new Repeater();
rep2.dataProvider = a;

var cd:Array = new Array();
cd.push(new mx.core.UIComponentDescriptor({type: mx.controls.Button}));
rep2.childDescriptors = cd;

addChild(rep2);

angie
05-22-2008, 02:32 PM
Got it, I was missing the following call...
rep2.initializeRepeater(this,true);

Also, not much information about this out there so thought I'd include an example of setting properties on the UIComponentDescriptor also...
cd.push(new mx.core.UIComponentDescriptor({type: mx.controls.Button, propertiesFactory:function():Object { return {label: "Dynamic",width: 300}}}));

Durai_ram
02-25-2009, 09:20 AM
It's possible to add image & label with repeater using AS3.... How ? Give any reference or code.........

Thanx.