Highlight the first item in the tilelist in flex

225 views Asked by At

I am navigating the items of tile list using next and previous button. I need to highlight the first item in the tilelist by default ( like the first item is being selected by default)

1

There are 1 answers

3
Jason Sturges On

Just require selection, which will default select the first item:

<s:List requireSelection="true">
    <s:layout>
        <s:TileLayout />
    </s:layout>
</s:List>

Otherwise, you can set the selected index:

<s:List selectedIndex="0" />

Or...

<fx:Script>
    <![CDATA[
        public function selectFirstItem():void
        {
            list.selectedIndex = 0;
        }
    ]]>
</fx:Script>

<s:List id="list" />

Likewise if you're using the deprecated mx:TileList

<mx:TileList selectedIndex="0" />