import fl.controls.TileList; import fl.controls.ScrollBarDirection; var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); myTileList.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); myTileList.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"}); myTileList.direction = ScrollBarDirection.VERTICAL; myTileList.columnWidth = 300;//列宽度,并非图片宽度 myTileList.rowHeight = 134;//每一行的高度 myTileList.columnCount = 1;//列数 myTileList.rowCount = 2;//显示的行数 myTileList.move(10, 10); addChild(myTileList);
import fl.data.DataProvider; import flash.display.DisplayObject; import fl.controls.TileList; var aTl:TileList = new TileList(); var aBoxes:Array = new Array(); var i:uint=0; var colors:Array=new Array(0x00000,0xFF0000,0x0000CC,0x00CC00,0xFFFF00); var colorNames:Array=new Array("Midnight","Cranberry","Sky","Forest","July"); var dp:DataProvider = new DataProvider(); for (i=0; i < colors.length; i++) { aBoxes[i] = new MovieClip(); drawBox(aBoxes[i], colors[i]); dp.addItem( {label:colorNames[i], source:aBoxes[i]} ); } aTl.dataProvider=dp; aTl.columnWidth=110;//单个图片的列的宽度 aTl.rowHeight=130;//单个图片的行的高度 aTl.setSize(280,150); //整个TileList的宽度和高度; aTl.move(20, 20); aTl.setStyle("contentPadding", 5); addChild(aTl); //---------------------------------------------------------------------------------------- function drawBox(box:MovieClip,color:uint):void { box.graphics.beginFill(color, 1.0); box.graphics.drawRect(0, 0, 100, 100); box.graphics.endFill(); }