10basetom
12-18-2006, 01:11 AM
Hi guys,
I'm just getting started in Flex, using the Dashboard sample app as my training ground:
http://www.adobe.com/devnet/flex/samples/dashboard/
For anyone not familiar with this sample app, here's the basic layout:
dashboard.mxml - main application that calls AllRegions.mxml, RegionDetail.mxml, and RegionBreakdown.mxml
RevenueTimeline.mxml - provides chart class
AllRegions.mxml - subclass of RevenueTimeline that instantiates chart
RegionDetail.mxml - subclass of RevenueTimeline that instantiates chart
RegionBreakdown.mxml - pie chart panel
My goal is very simple: I've declared a variable in dashboard.mxml that contains the string "Revenue":
public var timeline:String = "Revenue";
All I'm trying to do is access this 'timeline' variable from within the RevenueTimeline, AllRegions, RegionDetail, and RegionBreakdown components. Right now "Revenue" is hard-coded everywhere (e.g., tool tips, column header in grid view), so was trying to do something like this instead:
private function formatDataTip(hitData:HitData):String
{
var name:String = hitData.item.name;
var revenue:Number = hitData.item.revenue;
return "<b>Month: " + name + "</b><br>' + timeline + ': " + cf.format(revenue);
}
What's holding me back is that I can't seem to find a way to pass the variable that I declared in dashboard.mxml to all of the other four components (RevenueTimeline, AllRegions, RegionDetail, RegionBreakdown). I'm at the end of my rope here, so I was hoping someone can offer a quick solution or lead me in the right direction. I've read about view states, but it seems a little over the top for me; I'm not changing layouts depending on states or anything.
After finding out how to change the tool tips to use the 'timeline' variable, my next goal is to also leverage this variable for the column headers in the grid view. For example, I would like to use my variable instead of hard-coding "Total Revenue" in the code below:
<mx:DataGridColumn dataField="name" headerText="Month" sortCompareFunction="sortByDates" />
<mx:DataGridColumn dataField="revenue" headerText="Total Revenue" labelFunction="dataGridCurrencyFormat" />
<mx:DataGridColumn dataField="average" headerText="Average Across Categories" labelFunction="dataGridCurrencyFormat" />
Does anyone have any suggestions on how to do this as well?
TIA!
Tom
I'm just getting started in Flex, using the Dashboard sample app as my training ground:
http://www.adobe.com/devnet/flex/samples/dashboard/
For anyone not familiar with this sample app, here's the basic layout:
dashboard.mxml - main application that calls AllRegions.mxml, RegionDetail.mxml, and RegionBreakdown.mxml
RevenueTimeline.mxml - provides chart class
AllRegions.mxml - subclass of RevenueTimeline that instantiates chart
RegionDetail.mxml - subclass of RevenueTimeline that instantiates chart
RegionBreakdown.mxml - pie chart panel
My goal is very simple: I've declared a variable in dashboard.mxml that contains the string "Revenue":
public var timeline:String = "Revenue";
All I'm trying to do is access this 'timeline' variable from within the RevenueTimeline, AllRegions, RegionDetail, and RegionBreakdown components. Right now "Revenue" is hard-coded everywhere (e.g., tool tips, column header in grid view), so was trying to do something like this instead:
private function formatDataTip(hitData:HitData):String
{
var name:String = hitData.item.name;
var revenue:Number = hitData.item.revenue;
return "<b>Month: " + name + "</b><br>' + timeline + ': " + cf.format(revenue);
}
What's holding me back is that I can't seem to find a way to pass the variable that I declared in dashboard.mxml to all of the other four components (RevenueTimeline, AllRegions, RegionDetail, RegionBreakdown). I'm at the end of my rope here, so I was hoping someone can offer a quick solution or lead me in the right direction. I've read about view states, but it seems a little over the top for me; I'm not changing layouts depending on states or anything.
After finding out how to change the tool tips to use the 'timeline' variable, my next goal is to also leverage this variable for the column headers in the grid view. For example, I would like to use my variable instead of hard-coding "Total Revenue" in the code below:
<mx:DataGridColumn dataField="name" headerText="Month" sortCompareFunction="sortByDates" />
<mx:DataGridColumn dataField="revenue" headerText="Total Revenue" labelFunction="dataGridCurrencyFormat" />
<mx:DataGridColumn dataField="average" headerText="Average Across Categories" labelFunction="dataGridCurrencyFormat" />
Does anyone have any suggestions on how to do this as well?
TIA!
Tom