blob: 782b2430485d4cfc8a41450ef20b2a7c9548def4 [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:Module 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
{
contact.name = nameTxt.text;
contact.address = address.text;
contact.city = city.text;
contact.state = state.text;
contact.zip = zip.text;
trace(contacts.contains(contact));
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"/>
</fx:Declarations>
<s:Panel title="TabBar Sample" width="100%" height="100%">
<s:TabBar id="tabs" left="8" y="2" dataProvider="{vs}"/>
<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:Module>