0

我正在使用 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 替换它以使图表动态化。我尝试将 ('greenleaf') 替换为 ({dropdownList.selectedItem}) ,但它不起作用,但也许我需要触发一个事件才能使其工作。

我是 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>
4

1 回答 1

0

尝试添加功能:

private function comboBoxChange():void
{
    var selectedName:String = dropDownList.selectedItem;
    getpool_ratings_yr1Result.token = pool_ratings_yr1Service.getpool_ratings_yr1(selectedName);

}

然后在您的 dropDownList 上添加一个更改事件监听器:

<s:DropDownList id="dropDownList" x="73" y="133"
                creationComplete="dropDownList_creationCompleteHandler(event)"
                labelField="lname"
                change="comboBoxChange()">
于 2012-05-09T08:26:03.513 回答