/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public class LiquidTileList extends TileList { /** * if true, when changing the size of the tiles * scrolls the list so the first tile from the previous * state is still visible */ public var keepVisibleItem:Boolean; public function LiquidTileList() { super(); setSkin(PictureCellRenderer); } /** * Overriding the draw method to inject * our method of calculating the number of * tiles that fit the screen * This method is called every time the width/height * is changed */ override protected function draw():void { var i:int; if (keepVisibleItem && firstVisibleItem) i = firstVisibleItem.index; scrollIndexVisible(0, 0); calculateColumns(); super.draw(); if (keepVisibleItem && i) scrollIndexVisible(i, 0); } /** * Calculates the number of tiles that fit * the width */ private function calculateColumns():void { var columnNumber:int = Math.floor( (width - (cellPadding * columnCount -1) ) / columnWidth); if (columnNumber != columnCount) columnCount = columnNumber; } }