[英]flashbuilder 4.6 - How do I include a sqlite db and copying to storageDirectory
[英]How do I use selectedItem from dropdown to populate linechart in FlashBuilder 4.6
我正在使用FlashBuilder 4.6,coldfusion 9和Sql Server 2005來按年用一個人的數據填充折線圖。 如果我在數據提供程序中使用固定的字符串,則可以很好地工作,但是我想通過使用所有可用個人的下拉列表來選擇個人。 折線圖使用的個人名稱與下拉菜單中的個人使用相同的格式。 Flashbuilder數據/服務將字段顯示為字符串,其中MS Sql Server表將其顯示為varchar(50)。
所附代碼顯示getpool_ratings_yr1Result.token = pool_ratings_yr1Service.getpool_ratings_yr1('greenleaf')選擇單個“ greenleaf”。 我想用下拉菜單中的selectedItem替換它,以使圖表變得動態。 我嘗試用({dropdownList.selectedItem})替換('greenleaf')無效,但是也許我需要觸發一個事件才能使其正常工作。
我是FlashBuilder和Flex的新手,但是已經閱讀了很多書,沒有發現任何結論性的東西。
任何幫助將不勝感激。 謝謝,威爾
<?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"
xmlns:pool_ratings_yr1service="services.pool_ratings_yr1service.*"
xmlns:pool_playerservice="services.pool_playerservice.*"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function linechart1_creationCompleteHandler(event:FlexEvent):void
{
getpool_ratings_yr1Result.token = pool_ratings_yr1Service.getpool_ratings_yr1('greenleaf');
}
protected function dropDownList_creationCompleteHandler(event:FlexEvent):void
{
getAllpool_playerResult.token = pool_playerService.getAllpool_player();
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getpool_ratings_yr1Result"/>
<pool_ratings_yr1service:Pool_ratings_yr1Service id="pool_ratings_yr1Service"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
showBusyCursor="true"/>
<s:CallResponder id="getAllpool_ratings_yr1Result"/>
<s:CallResponder id="getAllpool_playerResult"/>
<pool_playerservice:Pool_playerService id="pool_playerService"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
showBusyCursor="true"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:LineChart id="linechart1" x="234" y="97"
creationComplete="linechart1_creationCompleteHandler(event)"
dataProvider="{getpool_ratings_yr1Result.lastResult}" showDataTips="true">
<mx:series>
<mx:LineSeries id="lineSeries" displayName="Series 1" yField="avg_rating"/>
</mx:series>
<mx:horizontalAxis>
<mx:CategoryAxis id="categoryAxis" categoryField="yr"/>
</mx:horizontalAxis>
</mx:LineChart>
<mx:Legend dataProvider="{linechart1}"/>
<s:DropDownList id="dropDownList" x="73" y="133"
creationComplete="dropDownList_creationCompleteHandler(event)"
labelField="lname">
<s:AsyncListView list="{getAllpool_playerResult.lastResult}"/>
</s:DropDownList>
</s:Application>
嘗試添加功能:
private function comboBoxChange():void
{
var selectedName:String = dropDownList.selectedItem;
getpool_ratings_yr1Result.token = pool_ratings_yr1Service.getpool_ratings_yr1(selectedName);
}
然后在您的dropDownList上添加一個change eventListener:
<s:DropDownList id="dropDownList" x="73" y="133"
creationComplete="dropDownList_creationCompleteHandler(event)"
labelField="lname"
change="comboBoxChange()">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.