Skip to content


[AS 3] TileList Component

A simple example of loading in some images in the TileList component. Make sure you add the TileList component to your library in or for this to work.

Here is the document class TileListDemo.as:

/*
Reference
http://www.adobe.com/devnet/flash/quickstart/tilelist_component_as3/
*/
package
{
	import flash.display.Sprite;
	import fl.controls.TileList;
	import fl.controls.ScrollBarDirection;
	import flash.text.TextFormat;

	public class TileListDemo extends Sprite
	{
		private var tlc:TileList;

		public function TileListDemo()
		{
			// create TileList instance
			var tlc:TileList = new TileList();

			// create TextFormat object to style labels
			var tf:TextFormat = new TextFormat();
			tf.font = "Verdana";
			tf.bold = true;
			tf.color = 0xFF6666;
			tf.size = 14;

			// add content to the TileList
			tlc.addItem({label:"Image 1", source:"http://manewc.com/projects/flash/TileList/1.jpg"});
			tlc.addItem({label:"Image 2", source:"http://manewc.com/projects/flash/TileList/2.jpg"});
			tlc.addItem({label:"Image 3", source:"http://manewc.com/projects/flash/TileList/3.jpg"});
			tlc.addItem({label:"Image 4", source:"http://manewc.com/projects/flash/TileList/4.jpg"});
			tlc.addItem({label:"Image 5", source:"http://manewc.com/projects/flash/TileList/5.jpg"});
			tlc.addItem({label:"Image 6", source:"http://manewc.com/projects/flash/TileList/6.jpg"});

			// set column and row values
			tlc.columnWidth = 500;
			tlc.rowHeight = 300;
			tlc.columnCount = 1;
			tlc.rowCount = 1;
			tlc.height = 320;
			tlc.width = 500;

			// enable scrolling
			tlc.scrollPolicy = "on";

			// position
			tlc.move(stage.stageWidth/2 - tlc.width / 2,stage.stageHeight/2 - tlc.height/2);

			// add to the display
			addChild(tlc); 

			// set style for labels
			tlc.setRendererStyle("textFormat", tf);
			tlc.setRendererStyle("imagePadding", 5);
		}
	}
}

Posted in Actionscript 3, Flash Components.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.