public function setShop():void
{
// shopList2.removeAllElements();
// var list:VGroup = new VGroup();
// list.percentWidth = 100;
// list.percentHeight = 100;
if(!shopes)return;
// var scroll:Scroller = new Scroller();
// scroll.percentWidth = 100;
// scroll.percentHeight = 100;
// scroll.setStyle("skinClass","com.wks.skins.scroller.Scroller_skin");
// skinClass="com.wks.skins.scroller.Scroller_skin"
// list.addElement(scroll);
// shopList.addElement(scroll);
var titlG:TileGroup = new TileGroup();
titlG.percentWidth = 100;
titlG.percentHeight = 100;
titlG.setStyle("horizontalAlign","center");
titlG.orientation = TileOrientation.ROWS;
titlG.autoLayout = true;
var slength:int = shopes.length;
for(var i:int=0; i<slength; i++)
{
var currshop:Shop = shopes.getItemAt(i) as Shop;
var vb:RowComp = new RowComp();
vb.rowData = currshop;
vb.cakeList = shopes;
vb.currentCakeIndex = i;
if(vb.cakename != null)
{
vb.setRow();
}
titlG.addElement(vb);
}
scroll.viewport = titlG;
// shopList.addElement(titlG);
titlG.addEventListener(ResizeEvent.RESIZE, changeSize);
}
private function changeSize(event:ResizeEvent):void
{
var currTile:TileGroup = event.currentTarget as TileGroup;
var rowNum:int = currTile.numElements;
if(rowNum > 0)
{
var tilewidth:Number = currTile.width;
var row:RowComp = currTile.getElementAt(0) as RowComp;
var rowwidth:Number = row.width;
var childNum:int = tilewidth/rowwidth;
if(childNum > 1)
{
currTile.horizontalGap = (tilewidth - row.width * childNum)/(childNum - 1);
}
}
}
转载于:https://blog.51cto.com/jie4lin/786545