如何在lineseries中动态分配displayName - tooltip& displayName显示[object Object]

时间:2012-05-11 02:44:25

标签: sql-server actionscript-3 flex flex4.5 coldfusion-9

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

我还想从下拉列表中动态地将相同的所选名称分配给lineseries的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>

1 个答案:

答案 0 :(得分:0)

不完全确定你的目标,但对于LineSeries displayName,这就是我所做的:

为每个Line Series创建一个[Bindable] String变量,然后每当数据发生变化时,只需为变量赋值即可。在您的示例中:

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;

    }

然后在你的mxml:

displayName="{myString}"

希望足够清楚!