main.mxml
[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="t开发者_如何学Crue"
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
[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>
QUES : Amount.mxml is used as dataTipRenderer for line chart. Now, I need to obtain the value assigned to variable "hx" in main.mxml from "com/Amount.mxml".Any help would be greatly appreciated?
You cant access the variable defined in one mxml in other mxml file as both files are compiled seperately. And the generated .swf are embeded in differnt html files . So as per I know its not possible. Plz let me know if i am going wrong.
Thanks
Prashant
精彩评论