ApplicationControlBar组件及creationComplete

1.flex加载完成后,可以调用方法,包括httpservice或urlloader等

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	creationComplete="catRPC.send()">
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;

			private function resultHandler(event:ResultEvent):void{
				//dosomething
			}

		]]>
	</mx:Script>

	<mx:HTTPService id="catRPC"
		url="http://www.flexgrocer.com/category.xml"
		result="resultHandler(event)"/>
</mx:Application>

 2.ApplicationControlBar组件的dock属性有true或false两个值,为true的时候是停靠模式,在application的上方不会随滚动条上下移动。ApplicationControlBar里可以包含Button,CombBox,MenuBar.通常将applicationControlBar放在容器的顶部。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	xmlns:v="views.dashboard.*"
	layout="horizontal"
	creationComplete="catRPC.send()">
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;

			[Bindable]
			private var categories:ArrayCollection=new ArrayCollection();

			private function catHandler(event:ResultEvent):void{
				categories = event.result.catalog.category;
				var catObj:Object = new Object();
				catObj.name = "All";
				catObj.categoryID = 0;
				categories.addItemAt(catObj, 0);
				catCombo.selectedIndex = 0;
			}

		]]>
	</mx:Script>

	<mx:HTTPService id="catRPC"
		url="http://www.flexgrocer.com/category.xml"
		result="catHandler(event)"/>

	<mx:ApplicationControlBar dock="true">
		<mx:LinkButton label="All"
			click="this.currentState=''"/>
		<mx:LinkButton label="Sales"
			click="this.currentState='fullSales'"/>
		<mx:LinkButton label="Categories"
			click="this.currentState='fullType'"/>
		<mx:LinkButton label="Comparison"
			click="this.currentState='fullComp'"/>
		<mx:Spacer width="100%"/>
		<mx:Label text="Start Date"/>
		<mx:DateField id="startDate"/>
		
		<mx:Label text="End Date"/>
		<mx:DateField id="endDate"/>

		<mx:ComboBox id="catCombo"
			dataProvider = "{categories}"
			labelField = "name"/>
		
		<mx:RadioButtonGroup id="grossOrNetGroup"/>
		
		<mx:RadioButton id="gross"
			groupName="grossOrNetGroup"
			label="Gross Sales"
			data="GROSS"
			selected="true"/>
		<mx:RadioButton id="net"
			groupName="grossOrNetGroup"
			label="Net Sales"
			data="NET"/>
	</mx:ApplicationControlBar>

	<mx:states>
		<mx:State name="fullSales">
			<mx:SetProperty target="{rightCharts}"
				name="width" value="0"/>
			<mx:SetProperty target="{rightCharts}"
				name="height" value="0"/>
		</mx:State>

		<mx:State name="fullType">
			<mx:SetProperty target="{sales}"
				name="width"
				value="0"/>
			<mx:SetProperty target="{sales}"
				name="height"
				value="0"/>
			<mx:SetProperty target="{comp}"
				name="width"
				value="0"/>
			<mx:SetProperty target="{comp}"
				name="height"
				value="0"/>
		</mx:State>
		<mx:State name="fullComp">
			<mx:SetProperty target="{sales}"
				name="width"
				value="0"/>
			<mx:SetProperty target="{sales}"
				name="height"
				value="0"/>
			<mx:SetProperty target="{type}"
				name="width"
				value="0"/>
			<mx:SetProperty target="{type}"
				name="height"
				value="0"/>
		</mx:State>
	</mx:states>

	<v:ChartPod id="sales"
	width="100%" height="100%"
	title="Sales Chart">
	</v:ChartPod>
	<mx:VBox id="rightCharts"
		width="100%" height="100%" >
		<v:ChartPod id="type"
			width="100%" height="100%"
			title="Category Chart">
		</v:ChartPod>
		<v:ChartPod id="comp"
			width="100%" height="100%"
			title="Comparison Chart">
		</v:ChartPod>
	</mx:VBox>
</mx:Application>

 程序中state的

<mx:SetProperty target="{rightCharts}" name="height" value="0"/>

是设置状态的属性,target是设置的目标,name是目标的属性,value是此属性的值,此行将rightCharts的height和width都设置为0,则界面中就相当于隐藏掉了rightCharts组件。

你可能感兴趣的:(组件)