package
{
import flash.display.MovieClip;
import fl.controls.*;
import fl.data.DataProvider;
import fl.events.ListEvent;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
public class Tilelist extends MovieClip
{
private var imagesURL:String = "";
private var myTileList:TileList = new TileList();
private var imagesArr:Array = new Array();
private var arr:Array = new Array();
public function Tilelist()
{
for (var i:uint = 1; i < 5; i++)
{
imagesArr.push({source:imagesURL + i + ".jpg", label:"Image " + i});
}
var dp:DataProvider = new DataProvider(imagesArr);
// myTileList.direction = ScrollBarDirection.VERTICAL;
myTileList.labelField ="";
myTileList.dataProvider = dp;
myTileList.columnWidth = 210;
myTileList.rowHeight = 98;
myTileList.columnCount = 3;
myTileList.move(-50, 280);
myTileList.addEventListener(ListEvent.ITEM_CLICK,onGetImageHandler);
addChild(myTileList);
}
private function onGetImageHandler(e:ListEvent):void
{
for (var j:int = 1; j < 5; j++)
{
var loader:Loader = new Loader();
loader.load(new URLRequest(String("p"+ j + ".jpg")));
arr.push(loader);
}
if(e.item.label == "Image 1")
{
arr[0].x = 200;
arr[0].y = 50;
stage.addChild(arr[0]);
}else if(e.item.label == "Image 2")
{
arr[1].x = 200;
arr[1].y = 50;
stage.addChild(arr[1]);
}else if(e.item.label == "Image 3")
{
arr[2].x = 200;
arr[2].y = 50;
stage.addChild(arr[2]);
}else if(e.item.label == "Image 4")
{
arr[3].x = 200;
arr[3].y = 50;
stage.addChild(arr[3]);
}
}
}
}