Flex4 ToggleButtonBar c иконками. Переключение состояний при помощи ToggleButtonBar.

Пример для Flash Builder.

ToggleButtonBar будет содержать 2 кнопки – Home и Downloads (рис. 1 и рис. 2), которые должны отображать соответствующую иконку и переключаться между состояниями.

Рис. 1 - Пример HomeState

Рис. 2 - Пример DownloadsState

<s:states>

<s:State name=“HomeState”/>

<s:State name=“DownloadsState”/>

</s:states>

<fx:Script>
<!–[CDATA[–>

import mx.events.ItemClickEvent;

protected function toggleBtnBar_itemClickHandler(event:ItemClickEvent):void
{

this.currentState = event.item.data;

}

]]>
</fx:Script>

<fx:Declarations>

<!– Place non-visual elements (e.g., services, value objects) here –>
<fx:Array id=”menuDataProvider”>

<fx:Object data=”HomeState

label=”Home

icon=”@Embed(source=’/assets/menu_icons/home.png’)/>

<fx:Object data=”DownloadsState

label=”Downloads

icon=”@Embed(source=’/assets/menu_icons/downloads.png’)/>

</fx:Array>

</fx:Declarations>

<mx:ToggleButtonBar id=”toggleBtnBar

iconField=”icon

dataProvider=”{menuDataProvider}

itemClick=”toggleBtnBar_itemClickHandler(event)” />

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s