Thursday, November 12, 2009

Create dynamic repeater in as3

here i m writing code for create dynamic repeater in as3...
in my code i try to show the images in vbox through the repeater...
in mxml application we directly give data provider and source to the image.. but in as ae should use loop for increment the data provider, otherwise we get first record of the repeater, it wont repeat the all the records....

here is my code, hope this will help to someone

cat.img is my xml

box_v=new VBox();
box_v.height=300;
addChild(box_v);
rep=new Repeater();
rep.setStyle("verticalCenter","0");
rep.setStyle("horizontalCenter","0");
var Y:int=25;
for(var i:int=0;i
{
rep.dataProvider=cat.img[i];
babyactimg=new Image();
babyactimg.source=rep.currentItem.@src;
//Alert.show((rep.currentItem.valueOf()).toString());
babyactimg.height=62;
babyactimg.width=62;

//set position for records
if(i>=0)
{
babyactimg.y=Y;
Y+=babyactimg.height;
}
rep.addChild(babyactimg);
}
box_v.addChild(rep);

No comments:

Post a Comment