Flex4 HorizontalList Example

Nov 30th, 2010 | Posted by Michael

Following example show how use spark list become to HorizontalList.

MyList.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
				xmlns:s="library://ns.adobe.com/flex/spark"
				xmlns:mx="library://ns.adobe.com/flex/mx"
				autoDrawBackground="true"
				alternatingItemColors="[0x000000]"
				rollOverColor="0x302f2f">
	<s:states>
		<s:State name="normal"/>
		<s:State name="hovered"/>
		<s:State name="selected"/>
		<s:State name="default"/>
	</s:states>
	<s:layout>
		<s:VerticalLayout horizontalAlign="center"/>
	</s:layout>
	<mx:Image source="listimages/{data.photo}"
			  width="150"
			  height="150"/>
	<s:Label text="{data.label}"
			 color="0xFFFFFF"
			 color.hovered="0xfd9604"
			 color.selected="0x000000"/>

</s:ItemRenderer>

HorizontalListExample.mxml

<?xml version="1.0" encoding="utf-8"?>
<!--created:Sep 14, 2010 file:HorizontalListExample.mxml  author:Michael -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" viewSourceURL="srcview/index.html">

	<s:layout>
		<s:VerticalLayout verticalAlign="middle"
						  horizontalAlign="center"/>
	</s:layout>
	<fx:Script>
		<![CDATA[
			import comp.MyList;

			import mx.collections.ArrayCollection;
			[Bindable]
			private var listDB:ArrayCollection=new ArrayCollection([{label: "images1", photo: "image1.png"},
				{label: "images2", photo: "image2.png"},
				{label: "images3", photo: "image3.png"},
				{label: "images4", photo: "image4.png"},
				{label: "images5", photo: "image5.png"},
				{label: "images6", photo: "image6.png"},
				{label: "images7", photo: "image7.png"},
				{label: "images8", photo: "image8.png"}]);
		]]>
	</fx:Script>

	<s:List dataProvider="{listDB}"
			itemRenderer="comp.MyList"
			width="300">
		<s:layout>
			<s:HorizontalLayout columnWidth="150"
								gap="0"/>
		</s:layout>
	</s:List>
</s:Application>

Demo and Source

Originally posted 2010-09-14 03:50:29.

  1. information technology
    Sep 14th, 2010 at 07:04
    Reply | Quote | #1

    This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

  2. madalyon
    Jan 24th, 2011 at 03:44
    Reply | Quote | #2

    Thank you for your work. was beautiful

*

Popular Arichives