blob: 076f80c8afd92edca5d036879ae34841c1e18ec6 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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" xmlns:local="*">
<fx:Script>
<![CDATA[
import mx.events.ListEvent;
//[Bindable]
//private var contact:Contact = new Contact();
protected function submitBtn_clickHandler(event:MouseEvent):void
{
// Note: this sample uses bidirectional data binding, so we do not have to
// explicitly set the contact fields to save them!
if (!contacts.contains(contact))
contacts.addItem(contact);
contact = new Contact();
}
protected function dg_itemClickHandler(event:ListEvent):void
{
contact = dg.selectedItem as Contact;
}
]]>
</fx:Script>
<fx:Declarations>
<s:ArrayCollection id="contacts"/>
<local:Contact id="contact"/>
</fx:Declarations>
<s:Panel width="100%" height="100%" title="TabBar Sample with Bidirectional Binding">
<s:layout>
<s:VerticalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"/>
</s:layout>
<s:TabBar id="tabs" dataProvider="{vs}" cornerRadius="4"/>
<mx:ViewStack id="vs" width="95%" height="85%" left="8" y="23">
<s:NavigatorContent label="Contact Info" width="100%" height="100%">
<s:BorderContainer width="100%" height="100%" dropShadowVisible="false">
<mx:Form id="contactForm" defaultButton="{submitBtn}" width="100%" height="100%">
<mx:FormItem label="Name:">
<s:TextInput id="nameTxt" text="@{contact.name}"/>
</mx:FormItem>
<mx:FormItem label="Address:">
<s:TextInput id="address" text="@{contact.address}"/>
</mx:FormItem>
<mx:FormItem label="City:">
<s:TextInput id="city" text="@{contact.city}"/>
</mx:FormItem>
<mx:FormItem label="State:">
<s:TextInput id="state" text="@{contact.state}"/>
</mx:FormItem>
<mx:FormItem label="Zip:">
<s:TextInput id="zip" text="@{contact.zip}" maxChars="5"/>
</mx:FormItem>
<mx:FormItem>
<s:Button id="submitBtn" label="Submit" click="submitBtn_clickHandler(event)"/>
</mx:FormItem>
</mx:Form>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent label="Contact List" width="100%" height="100%" >
<s:BorderContainer width="100%" height="100%" dropShadowVisible="false">
<mx:DataGrid id="dg" dataProvider="{contacts}" x="5" y="5" doubleClickEnabled="true"
doubleClick="{tabs.selectedIndex=0}" itemClick="dg_itemClickHandler(event)">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Address" dataField="address"/>
<mx:DataGridColumn headerText="City" dataField="city"/>
<mx:DataGridColumn headerText="State" dataField="state"/>
<mx:DataGridColumn headerText="Zip" dataField="zip"/>
</mx:columns>
</mx:DataGrid>
</s:BorderContainer>
</s:NavigatorContent>
</mx:ViewStack>
</s:Panel>
</s:Application>