f​l​e​x​学​习​笔​记​3 ​H​t​t​p​S​e​r​v​i​c​e

<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600" initialize="employeeService.send()">
	<s:layout>
		<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
	</s:layout>
	<fx:Script>
		<![CDATA[
			import com.model.Person;
			import mx.collections.ArrayCollection;
			import spark.events.DropDownEvent; 
			import mx.binding.utils.BindingUtils;
			import mx.controls.Alert;
			import mx.rpc.events.ResultEvent;
			[Bindable]  
			private var	employeeData:ArrayCollection;

			[Bindable] 
			[Bindable] private	var	arr:ArrayCollection	 =	new ArrayCollection([{name:"李1",head:"11.jpg"},{name:"李2",head:"11.jpg"}]); 

			protected function	dropdownlist1_closeHandler(event:DropDownEvent):void
			{ 
				Alert.show(obj.selectedItem.name);
			}
			private function resultHandler(event:ResultEvent):void	
			{ 
				employeeData=event.result.department.employee;
				//Alert.show("---------");
			}

		]]>
	</fx:Script>
		
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		<mx:HTTPService id="employeeService" url="http://127.0.0.1:8383/Xml/employees.xml"  result="resultHandler(event)">
		</mx:HTTPService>
   </fx:Declarations>
   <mx:DataGrid	dataProvider="{employeeData}"></mx:DataGrid>
   <s:DropDownList id="obj" width="200" dataProvider="{arr}" labelField="name" close="dropdownlist1_closeHandler(event)" itemRenderer="com.test.TT"></s:DropDownList>


</s:Application>

 

 

<?xml version="1.0" encoding="UTF-8"?>
 
<department>
<employee id="1234">
	<name>james</name> 
	<sex>male</sex>
	<age>25</age>
	<title>manager</title>
	<desc>got merried</desc>
</employee>

<employee id="1235">
	<name>james11</name> 
	<sex>male</sex>
	<age>25</age>
	<title>manager</title>
	<desc>got merried</desc>
</employee>

<employee id="127">
	<name>james11</name> 
	<sex>male</sex>
	<age>26</age>
	<title>manager</title>
	<desc>got merried</desc>
</employee>
</department>

 

 

 TT.MXML

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
				xmlns:s="library://ns.adobe.com/flex/spark" 
				xmlns:mx="library://ns.adobe.com/flex/mx" 
				autoDrawBackground="true">
	<s:BitmapImage		x="5"		width="50"		height="50"		source="{data.head}" verticalCenter="0"/>

	<s:Label x="65"	text="{data.name}" verticalCenter="0"/>
	
</s:ItemRenderer>

 

 

 

http://wenku.baidu.com/view/5af0d30e7cd184254b3535e2.html

 

 

你可能感兴趣的:(c)