Search Flex Components Free

Custom Search

December 25, 2007

Flex Panel with ControlBar Source Code Sample

Flex Panels and Windows Sample Source Code:
Create a file:
ControlBarDemo.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="srv.send()">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
public var employees:ArrayCollection;

private function deleteItem() : void
{
if (dg.selectedIndex >= 0 && dg.selectedIndex < employees.length)
employees.removeItemAt(dg.selectedIndex);
}
]]>
</mx:Script>

<mx:HTTPService id="srv" url="../assets/employees.xml" useProxy="false"
result="employees = new ArrayCollection(srv.lastResult.list.employee)"/>

<mx:Panel title="Employee List" width="100%" height="100%">

<mx:DataGrid id="dg" width="100%" height="100%" dataProvider="{employees}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="phone" headerText="Phone"/>
<mx:DataGridColumn dataField="email" headerText="Email"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>

<mx:ControlBar>
<mx:Button label="Delete" click="deleteItem()"/>
</mx:ControlBar>

</mx:Panel>

</mx:Application>


employees.xml

<?xml version="1.0" encoding="utf-8"?>

<list>

<employee>
<name>Christina Coenraets</name>
<phone>555-219-2270</phone>
<email>ccoenraets@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Louis Freligh</name>
<phone>555-219-2100</phone>
<email>lfreligh@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Ronnie Hodgman</name>
<phone>555-219-2030</phone>
<email>rhodgman@fictitious.com</email>
<active>false</active>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555-219-2012</phone>
<email>jwall@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Maurice Smith</name>
<phone>555-219-2012</phone>
<email>maurice@fictitious.com</email>
<active>false</active>
</employee>
<employee>
<name>Mary Jones</name>
<phone>555-219-2000</phone>
<email>mjones@fictitious.com</email>
<active>true</active>
</employee>

</list>




Related Flex Tutorials