0

此 flashbuilder 4.6 应用程序根据从下拉列表中选择的名称在折线图上显示单个 lineSeries,并且lineseries 数据显示良好。但是,工具提示显示 [object Playername_returntype] 而不是下拉选择的名称。

我还想从下拉列表中动态地将相同的选择名称分配给 lineeries 的 displayName,但无法实现这一点。结果显示 [object Playername_returntype],如工具提示中所示。

任何帮助将非常感激。

谢谢。

   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();
        }

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

        }


    ]]>
</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="151" y="88" width="800"
              creationComplete="linechart1_creationCompleteHandler(event)"
              dataProvider="{getpool_ratings_yr1Result.lastResult}" showDataTips="true">
    <mx:verticalAxis>
        <mx:LinearAxis id="v1" minimum="2000" maximum="2500" title="Average Elo Rating" /> 
    </mx:verticalAxis> 
    <mx:series>
        <mx:LineSeries id="lineSeries" displayName="{dropDownList.selectedItem}" 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="10" y="88"
                creationComplete="dropDownList_creationCompleteHandler(event)"
                labelField="lname"
                change="comboBoxChange()">
    <s:AsyncListView list="{getAllpool_playerResult.lastResult}"/>
</s:DropDownList>

4

1 回答 1

0

Not entirely sure what you're after, but for the LineSeries displayName, here's what I did:

Created a [Bindable] String variable for each Line Series, and then whenever the data changed, just assign whatever value you want to the variable. In your example:

private function comboBoxChange():void
    {
        var selectedName:String = dropDownList.selectedItem.lname;
        getpool_ratings_yr1Result.token = pool_ratings_yr1Service.getpool_ratings_yr1(selectedName);
        // Private Bindable String variable(myString) assigned earlier
        myString = selectedName;

    }

And then in your mxml:

displayName="{myString}"

Hope that's clear enough!

于 2013-01-09T15:53:01.300 回答