Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 142407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:55:54+00:00 2026-05-11T07:55:54+00:00

I have a component with two Pie Charts that display percentages at two specific

  • 0

I have a component with two Pie Charts that display percentages at two specific dates (think start and end values). But, I have three views: Start Value only, End Value only, or show Both. I am using a ToggleButtonBar to control the display. What is the best practice for changing this kind of view state? Right now (since this code was inherited), the view states are changed in an ActionScript function which sets the visible and includeInLayout properties on each Pie Chart based on the selectedIndex of the ToggleButtonBar, but, this just doesn’t seem like the best way to do this – not very dynamic. I’d like to be able to change the state based on the name of the selectedItem, in case the order of the ToggleButtons changes, and since I am storing the name of the selectedItem for future reference.

Would using States be better? If so, what would be the best way to implement this?

Thanks.

Current logic:

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> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:55:54+00:00Added an answer on May 11, 2026 at 7:55 am

    Since the currentState property takes a String, which maps to the name property of a state, then it sounds like using <mx:states> would work well in your case. In fact I use states often for toggling between views in just the way you describe — setting visible and includeInLayout properties of components (usually Canvas components, or other sorts of containers) with SetProperty:

    <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> 

    … following this general pattern. Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ascx component, that holds two-level menu, because there are several user
I have a visual component that I built from a TFrame (but then registered
I'd like to have a TabNavigator component that has a close button for some
I have 2 ArrayLists that have a Array of Strings as a component. I
I have a TextArea component called labels that will be populated by Strings in
I am creating an application in which I have two mxml components, MainPanel.mxml and
I have a component which writes/generates javascript from a server side renderer. This component
I have a component which has a List<T> property. The class in the list
I have a custom component where I have implemented INotifyPropertyChanged and IBindableComponent . However,
I have a .NET component exposed as a CCW (Com Callable Wrapper) and being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.