我正在使用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>
答案 0 :(得分:0)
尝试添加功能:
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()">