天天看點

Alternating tile background colors for items in a TileList control in Flex

The following example shows how you can set alternating background colors for tiles in a Flex TileList control by setting the <code>alternatingItemColors</code> style using MXML, CSS or ActionScript.

Full code after the jump.

<a></a>

&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;!-- http://blog.flexexamples.com/2008/08/10/alternating-tile-background-colors-for-items-in-a-tilelist-control-in-flex/ --&gt;

&lt;mx:Application name="TileList_alternatingItemColors_test"

        xmlns:mx="http://www.adobe.com/2006/mxml"

        layout="vertical"

        verticalAlign="middle"

        backgroundColor="white"&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;

        &lt;mx:source&gt;

            &lt;mx:Array&gt;

                &lt;mx:Object label="One" /&gt;

                &lt;mx:Object label="Two" /&gt;

                &lt;mx:Object label="Three" /&gt;

                &lt;mx:Object label="Four" /&gt;

                &lt;mx:Object label="Five" /&gt;

                &lt;mx:Object label="Six" /&gt;

                &lt;mx:Object label="Seven" /&gt;

                &lt;mx:Object label="Eight" /&gt;

                &lt;mx:Object label="Nine" /&gt;

                &lt;mx:Object label="Ten" /&gt;

                &lt;mx:Object label="Eleven" /&gt;

                &lt;mx:Object label="Twelve" /&gt;

            &lt;/mx:Array&gt;

        &lt;/mx:source&gt;

    &lt;/mx:ArrayCollection&gt;

    &lt;mx:TileList id="tileList"

            dataProvider="{arrColl}"

            columnCount="4"

            columnWidth="120"

            rowCount="3"

            rowHeight="80"

            alternatingItemColors="[#FFFFFF,#CCCCCC,#999999]" /&gt;

&lt;/mx:Application&gt;

    本文轉自 OldHawk  部落格園部落格,原文連結:http://www.cnblogs.com/taobataoma/archive/2008/08/28/1278198.html,如需轉載請自行聯系原作者