首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从其他main.mxml检索.mxml的值?

如何从其他main.mxml检索.mxml的值?
EN

Stack Overflow用户
提问于 2010-04-23 05:29:08
回答 1查看 353关注 0票数 0

main.mxml

代码语言:javascript
运行
复制
        [Bindable]
        private var _dp:ArrayCollection = new ArrayCollection([
            {day:"Monday", dailyTill:7792.43},
            {day:"Tuesday", dailyTill:8544.875},
            {day:"Wednesday", dailyTill:6891.432},
            {day:"Thursday", dailyTill:10438.1},
            {day:"Friday", dailyTill:8395.222},
            {day:"Saturday", dailyTill:5467.00},
            {day:"Sunday", dailyTill:10001.5}
        ]);

        public var hx:String ;
        public function init():void
         {
            //parameters is passed to it from flashVars
            //values are either amount or order
            hx = Application.application.parameters.tab;
         }
    ]]>
</mx:Script>


<mx:LineChart
    id="myLC"
    dataProvider="{_dp}"
    showDataTips="true"
    dataTipRenderer="com.Amount"
>
    <mx:horizontalAxis>
        <mx:CategoryAxis categoryField="day" />
    </mx:horizontalAxis>
    <mx:series>
        <mx:LineSeries xField="day" yField="dailyTill">
        </mx:LineSeries>
    </mx:series>
</mx:LineChart>

com/Amount.mxml

代码语言:javascript
运行
复制
        [Bindable]
        private var _dayText:String;

        [Bindable]
        private var _dollarText:String;

        override public function set data(value:Object):void{
            //Alert.show(Application.application.parameters.tab);
            //we know to expect a HitData object from a chart, so let's cast it as such
            //so that there aren't any nasty runtime surprises
            var hd:HitData = value as HitData;

            //Any HitData object carries a reference to the ChartItem that created it.
            //This is where we need to know exactly what kind of Chartitem we're dealing with.
            //Why? Because a pie chart isn't going to have an xValue and a yValue, but things
            //like bar charts, column charts and, in our case, line charts will.
            var item:LineSeriesItem = hd.chartItem as LineSeriesItem;

            //the xValue and yValue are returned as Objects. Let's cast them as strings, so
            //that we can display them in the Label fields.
            _dayText =  String(item.xValue);
            _dollarText = String(item.yValue);
        }//end set data
    ]]>
</mx:Script>

问题: Amount.mxml是用于线图的dataTipRenderer。现在,我需要从“com/Amount.mxml”的main.mxml帮助中获得分配给变量"hx“的值,这样会非常感谢吗?

EN

回答 1

Stack Overflow用户

发布于 2010-04-23 05:42:55

在另一个mxml文件中不能访问定义在一个mxml中的变量,因为这两个文件都是单独编译的。生成的.swf嵌入到不同的html文件中。所以据我所知这是不可能的。如果我做错了,请告诉我。

谢谢

普拉尚特

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2696409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档