Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function pieTypeToggleButtonBar_itemClickHandler():void
- {
- // Show/Hide the appropriate Pie Charts based on the user's selection
- switch (pieTypeToggleButtonBar.selectedIndex)
- {
- // "Start Value" is selected
- case 0:
- {
- // Hide the End Value Pie Chart
- endValuePieChartVBox.visible = false;
- endValuePieChartVBox.includeInLayout = false;
- // Show the Start Value Pie Chart
- startValuePieChartVBox.includeInLayout = true;
- startValuePieChartVBox.visible = true;
- break;
- }
- // "End Value" is selected
- case 1:
- {
- // Hide the Start Value Pie Chart
- startValuePieChartVBox.visible = false;
- startValuePieChartVBox.includeInLayout = false;
- // Show the End Value Pie Chart
- endValuePieChartVBox.includeInLayout = true;
- endValuePieChartVBox.visible = true;
- break;
- }
- // "Both" is selected
- case 2:
- {
- // Show the Start Value Pie Chart
- startValuePieChartVBox.includeInLayout = true;
- startValuePieChartVBox.visible = true;
- // Show the End Value Pie Chart
- endValuePieChartVBox.includeInLayout = true;
- endValuePieChartVBox.visible = true;
- break;
- }
- }
- }
- <mx:ToggleButtonBar id="pieTypeToggleButtonBar" selectedIndex="1"
- itemClick="pieTypeToggleButtonBar_itemClickHandler()">
- <mx:Array>
- <mx:Object name="startValue" label="Start Value" />
- <mx:Object name="endValue" label="End Value" />
- <mx:Object name="both" label="Both" />
- </mx:Array>
- </mx:ToggleButtonBar>
- <mx:states>
- <mx:State name="View State 1">
- <mx:SetProperty target="{component1}" name="visible" value="true" />
- <mx:SetProperty target="{component2}" name="visible" value="false" />
- <mx:SetProperty target="{component3}" name="visible" value="false" />
- <mx:SetProperty target="{component1}" name="includeInLayout" value="true" />
- <mx:SetProperty target="{component2}" name="includeInLayout" value="false" />
- <mx:SetProperty target="{component3}" name="includeInLayout" value="false" />
- </mx:State>
- <mx:State name="View State 2">
- <mx:SetProperty target="{component1}" name="visible" value="false" />
- <mx:SetProperty target="{component2}" name="visible" value="true" />
- <mx:SetProperty target="{component3}" name="visible" value="false" />
- <mx:SetProperty target="{component1}" name="includeInLayout" value="false" />
- <mx:SetProperty target="{component2}" name="includeInLayout" value="true" />
- <mx:SetProperty target="{component3}" name="includeInLayout" value="false" />
- </mx:State>
- <mx:State name="View State 3">
- <mx:SetProperty target="{component1}" name="visible" value="false" />
- <mx:SetProperty target="{component2}" name="visible" value="false" />
- <mx:SetProperty target="{component3}" name="visible" value="true" />
- <mx:SetProperty target="{component1}" name="includeInLayout" value="false" />
- <mx:SetProperty target="{component2}" name="includeInLayout" value="false" />
- <mx:SetProperty target="{component3}" name="includeInLayout" value="true" />
- </mx:State>
- </mx:states>
- <mx:Script>
- <![CDATA[
- import mx.binding.utils.BindingUtils;
- import mx.binding.utils.ChangeWatcher;
- private function this_creationComplete(event:Event):void
- {
- // Use BindingUtils.bindSetter to hook into selectedIndex-change events
- var cw:ChangeWatcher = BindingUtils.bindSetter(setState, myBar, "selectedIndex");
- }
- private function setState(index:int):void
- {
- currentState = myBar.getChildren()[index].label;
- }
- ]]>
- </mx:Script>
- <mx:ToggleButtonBar id="myBar">
- <mx:dataProvider>
- <mx:Array>
- <mx:String>View State 1</mx:String>
- <mx:String>View State 2</mx:String>
- <mx:String>View State 3</mx:String>
- </mx:Array>
- </mx:dataProvider>
- </mx:ToggleButtonBar>
- <mx:Canvas id="component1">
- <mx:Text text="Component 1" />
- </mx:Canvas>
- <mx:Canvas id="component2">
- <mx:Text text="Component 2" />
- </mx:Canvas>
- <mx:Canvas id="component3">
- <mx:Text text="Component 3" />
- </mx:Canvas>
Add Comment
Please, Sign In to add comment